/** * {@inheritDoc} */ @Override public final RawLocationReference decodeData(final String id, final Object data) throws PhysicalFormatException { if (!(data instanceof GeoCoordinate)) { throw new OpenLRXMLException(XMLErrorType.DATA_ERROR, "incorrect data class"); } GeoCoordinate gCoord = (GeoCoordinate) data; GeoCoordinates geoCoord = createGeoCoord(gCoord.getCoordinates()); RawLocationReference rawLocRef = new RawGeoCoordLocRef(id, geoCoord); return rawLocRef; }
throw new OpenLRBinaryException(BinaryReturnCode.INVALID_BINARY_DATA, e); RawGeoCoordLocRef rawLocRef = new RawGeoCoordLocRef(id, geoCoord); if (binData != null) { binData.setBinaryAbsoluteCoordinates(absCoord);
/** * {@inheritDoc} */ @Override public final RawLocationReference doEncoding(final Location location, final OpenLREncoderParameter parameter) throws OpenLRRuntimeException { Configuration properties = parameter.getConfiguration(); MapDatabase mdb = parameter.getMapDatase(); // check if the location is valid LocationCheck locCheck = new GeoCoordinateLocationCheck(); CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef(location.getID(), retCode.getError(), location.getLocationType()); return invalid; } GeoCoordinates gc = null; try { gc = new GeoCoordinates(location .getPointLocation().getLongitudeDeg(), location .getPointLocation().getLatitudeDeg()); } catch (InvalidMapDataException e) { throw new OpenLREncoderRuntimeException(EncoderRuntimeError.INVALID_MAP_DATA, e); } RawLocationReference rawLocRef = new RawGeoCoordLocRef( location.getID(), gc); return rawLocRef; }