/** * {@inheritDoc} */ @Override public final RawLocationReference decodeData(final String id, final Object data) throws PhysicalFormatException { if (!(data instanceof PolygonLocationReference)) { throw new OpenLRXMLException(XMLErrorType.DATA_ERROR, "incorrect data class"); } PolygonLocationReference polygonLoc = (PolygonLocationReference) data; List<Coordinates> corners = polygonLoc.getPolygonCorners().getCoordinates(); if (corners == null || corners.size() < MIN_NUMBER_CORNERS) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_POLYGON_DATA, LocationType.POLYGON); } List<GeoCoordinates> cornerPoints = new ArrayList<GeoCoordinates>(); for (Coordinates geoCoord : corners) { cornerPoints.add(createGeoCoord(geoCoord)); } RawLocationReference rawLocRef = new RawPolygonLocRef(id, cornerPoints); return rawLocRef; }
.getLocationReferencePoint(); if (locPoints == null || locPoints.isEmpty()) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.LINE_LOCATION); .getLastLocationReferencePoint(); if (lastLRP == null) { return new RawInvalidLocRef(id, XmlReturnCode.NO_LAST_LRP_FOUND, LocationType.LINE_LOCATION);
OpenLRBinaryConstants.MIN_BYTES_CLOSED_LINE_LOCATION))) { LOG.error("not enough bytes in the stream"); return new RawInvalidLocRef(id, BinaryReturnCode.NOT_ENOUGH_BYTES); return new RawInvalidLocRef(id, BinaryReturnCode.READING_HEADER_FAILURE); return new RawInvalidLocRef(id, BinaryReturnCode.INVALID_VERSION); decoder = new GeoCoordDecoder(); } else { rawLocRef = new RawInvalidLocRef(id, BinaryReturnCode.INVALID_BYTE_SIZE); decoder = new PoiAccessDecoder(); } else { rawLocRef = new RawInvalidLocRef(id, BinaryReturnCode.INVALID_BYTE_SIZE); decoder = new ClosedLineDecoder(); } else { rawLocRef = new RawInvalidLocRef(id, BinaryReturnCode.INVALID_BYTE_SIZE); decoder = new GridDecoder(); } else { rawLocRef = new RawInvalidLocRef(id, BinaryReturnCode.INVALID_BYTE_SIZE); decoder = new PolygonDecoder(); } else { rawLocRef = new RawInvalidLocRef(id, BinaryReturnCode.INVALID_BYTE_SIZE);
/** * {@inheritDoc} */ @Override public final RawLocationReference decodeData(final String id, final Object data) throws PhysicalFormatException { if (!(data instanceof CircleLocationReference)) { throw new OpenLRXMLException(XMLErrorType.DATA_ERROR, "incorrect data class"); } CircleLocationReference circleLoc = (CircleLocationReference) data; long radius = circleLoc.getRadius().longValue(); GeoCoordinate centerPoint = circleLoc.getGeoCoordinate(); if (centerPoint == null || radius < 0) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_CIRCLE_DATA, LocationType.CIRCLE); } RawLocationReference rawLocRef = new RawCircleLocRef(id, createGeoCoord(centerPoint.getCoordinates()), radius); return rawLocRef; }
/** * {@inheritDoc} */ @Override public final RawLocationReference decodeData(final String id, final Object data) throws PhysicalFormatException { if (!(data instanceof RectangleLocationReference)) { throw new OpenLRXMLException(XMLErrorType.DATA_ERROR, "incorrect data class"); } RectangleLocationReference rectangleLoc = (RectangleLocationReference) data; Rectangle rect = rectangleLoc.getRectangle(); if (rect == null) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_RECTANGLE_DATA, LocationType.RECTANGLE); } Coordinates lowerLeftPoint = rect.getLowerLeft(); Coordinates upperRightPoint = rect.getUpperRight(); if (lowerLeftPoint == null || upperRightPoint == null) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_RECTANGLE_DATA, LocationType.RECTANGLE); } RawLocationReference rawLocRef = new RawRectangleLocRef(id, createGeoCoord(lowerLeftPoint), createGeoCoord(upperRightPoint)); return rawLocRef; }
/** * {@inheritDoc} */ @Override public final RawLocationReference decodeData(final String id, final Object data) throws PhysicalFormatException { if (!(data instanceof GridLocationReference)) { throw new OpenLRXMLException(XMLErrorType.DATA_ERROR, "incorrect data class"); } GridLocationReference gridLoc = (GridLocationReference) data; Rectangle rect = gridLoc.getRectangle(); if (rect == null) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_GRID_DATA, LocationType.GRID); } Coordinates lowerLeftPoint = rect.getLowerLeft(); Coordinates upperRightPoint = rect.getUpperRight(); if (lowerLeftPoint == null || upperRightPoint == null) { return new RawInvalidLocRef(id, XmlReturnCode.MISSING_GRID_DATA, LocationType.GRID); } int ncols = gridLoc.getNumColumns(); int nrows = gridLoc.getNumRows(); RawLocationReference rawLocRef = new RawGridLocRef(id, createGeoCoord(lowerLeftPoint), createGeoCoord(upperRightPoint), ncols, nrows); return rawLocRef; }
.getLocationReferencePoint(); if (locPoints == null || locPoints.isEmpty()) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.CLOSED_LINE);
/** * {@inheritDoc} */ @Override public final RawLocationReference doEncoding(final Location location, final OpenLREncoderParameter prop) throws OpenLRRuntimeException { Configuration properties = prop.getConfiguration(); MapDatabase mdb = prop.getMapDatase(); // check if the location is valid LocationCheck locCheck = new PolygonLocationCheck(); CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef(location.getID(), retCode.getError(), location.getLocationType()); return invalid; } List<? extends GeoCoordinates> cornerCoords = location.getCornerPoints(); RawLocationReference rawLocRef = new RawPolygonLocRef(location.getID(), cornerCoords); return rawLocRef; } }
CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType()); RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType());
CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType()); RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType());
/** * {@inheritDoc} */ @Override public final RawLocationReference doEncoding(final Location location, final OpenLREncoderParameter prop) throws OpenLRRuntimeException { Configuration properties = prop.getConfiguration(); MapDatabase mdb = prop.getMapDatase(); // check if the location is valid LocationCheck locCheck = new GridLocationCheck(); CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType()); return invalid; } RawLocationReference rawLocRef = new RawGridLocRef(location.getID(), location.getLowerLeftPoint(), location.getUpperRightPoint(), location.getNumberOfColumns(), location.getNumberOfRows()); return rawLocRef; } }
location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef(location.getID(), retCode.getError(), location.getLocationType()); return invalid; RawLocationReference invalid = new RawInvalidLocRef(location.getID(), retCode.getError(), location.getLocationType()); return invalid;
/** * {@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; }
/** * {@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 ClosedLineLocationCheck(); CheckResult retCode = locCheck.check(properties, mdb, location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType()); return invalid; } LocRefData lrd = new LocRefData(location); // initialize location reference data array and start encoding lrd.setLocRefPoints(generateLocRef(lrd, properties)); // check if the location reference meets all restrictions and adjust // length values if necessary LocationReferenceAdjust locRefAdjust = new ClosedLineLocRefAdjust(); locRefAdjust.adjustLocationReference(properties, lrd); RawLocationReference rawLocRef = new RawClosedLineLocRef( location.getID(), lrd.getLocRefPoints()); return rawLocRef; }
.getLastLocationReferencePoint(); if (startLRP == null || endLRP == null) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.POINT_ALONG_LINE);
RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType());
.getLastLocationReferencePoint(); if (startLRP == null || endLRP == null) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.POI_WITH_ACCESS_POINT);
location); if (!retCode.checkPassed()) { RawLocationReference invalid = new RawInvalidLocRef(location.getID(), retCode.getError(), location.getLocationType()); return invalid;