/** * Gets the lr ps. * * @return the LR ps * {@inheritDoc} */ @Override public final List<? extends LocationReferencePoint> getLRPs() { if (rawData == null || rawData.getLocationReferencePoints() == null) { return null; } return rawData.getLocationReferencePoints(); }
/** * Instantiates a new location reference holder with ID id and the location * references identified by their data identifier string. Additionally it * holds the raw location reference data. This location reference is valid. * * @param idString * the unique id * @param rd * the rd */ public LocationReferenceHolderImpl(final String idString, final RawLocationReference rd) { id = idString; returnCode = null; locType = rd.getLocationType(); rawData = rd; }
/** * {@inheritDoc} */ @Override public final LocationReference encodeData(final RawLocationReference rawLocRef, final int version) { List<? extends LocationReferencePoint> locRef = rawLocRef.getLocationReferencePoints(); Offsets od = rawLocRef.getOffsets(); if (locRef == null || od == null) { return new LocationReferenceXmlImpl(rawLocRef.getID(), XmlReturnCode.INVALID_DATA, LocationType.LINE_LOCATION, version); } OpenLR xmlData = OBJECT_FACTORY.createOpenLR(); String id = ""; if (rawLocRef.hasID()) { id = rawLocRef.getID(); } xmlData.setLocationID(id); XMLLocationReference xmlLoc = createXMLLineLocRef(locRef, od); xmlData.setXMLLocationReference(xmlLoc); LocationReference locRefData = new LocationReferenceXmlImpl(id, xmlData, version); return locRefData; }
/** * {@inheritDoc} */ @Override public final LocationReference encodeData( final RawLocationReference rawLocRef, final int version) { GeoCoordinates centerPoint = rawLocRef.getCenterPoint(); long radius = rawLocRef.getRadius(); if (centerPoint == null || radius < 0) { return new LocationReferenceXmlImpl(rawLocRef.getID(), XmlReturnCode.INVALID_DATA, LocationType.CIRCLE, version); } OpenLR xmlData = OBJECT_FACTORY.createOpenLR(); String id = ""; if (rawLocRef.hasID()) { id = rawLocRef.getID(); } xmlData.setLocationID(id); XMLLocationReference xmlLoc = createXMLCircleLocRef(centerPoint, radius); xmlData.setXMLLocationReference(xmlLoc); LocationReference locRefData = new LocationReferenceXmlImpl(id, xmlData, version); return locRefData; }
/** * {@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 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; }
/** * {@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; }
/** * {@inheritDoc} */ @Override public final LocationReference encodeData( final RawLocationReference rawLocRef, final int version) { List<? extends GeoCoordinates> cornerPoints = rawLocRef .getCornerPoints(); if (cornerPoints == null) { return new LocationReferenceXmlImpl(rawLocRef.getID(), XmlReturnCode.INVALID_DATA, LocationType.POLYGON, version); } OpenLR xmlData = OBJECT_FACTORY.createOpenLR(); String id = ""; if (rawLocRef.hasID()) { id = rawLocRef.getID(); } xmlData.setLocationID(id); XMLLocationReference xmlLoc = createXMLPolygonLocRef(cornerPoints); xmlData.setXMLLocationReference(xmlLoc); LocationReference locRefData = new LocationReferenceXmlImpl(id, xmlData, version); return locRefData; }
/** * {@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; }
.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); RawLocationReference rawLocRef = new RawLineLocRef(id, points, offsets); return rawLocRef;
/** * {@inheritDoc} */ @Override public final LocationReference encodeData(final RawLocationReference rawLocRef, final int version) { GeoCoordinates coord = rawLocRef.getGeoCoordinates(); OpenLR xmlData = OBJECT_FACTORY.createOpenLR(); String id = ""; if (rawLocRef.hasID()) { id = rawLocRef.getID(); } xmlData.setLocationID(id); XMLLocationReference xmlLoc = createXMLGeoCoordLocRef(coord); xmlData.setXMLLocationReference(xmlLoc); LocationReference locRefData = new LocationReferenceXmlImpl(id, xmlData, version); return locRefData; } }
.getLastLocationReferencePoint(); if (startLRP == null || endLRP == null) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.POINT_ALONG_LINE); orientation = resolveOrientation(pal.getOrientation()); RawLocationReference rawLocRef = new RawPointAlongLocRef(id, lrp01, lrp02, offsets, sideOfRoad, orientation); 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 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; }
.getLastLocationReferencePoint(); if (startLRP == null || endLRP == null) { return new RawInvalidLocRef(id, XmlReturnCode.INVALID_NUMBER_OF_LRP, LocationType.POI_WITH_ACCESS_POINT); orientation = resolveOrientation(palwap.getOrientation()); RawLocationReference rawLocRef = new RawPoiAccessLocRef(id, lrp01, lrp02, offsets, geoCoord, sideOfRoad, orientation); return rawLocRef;
/** * {@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; }
RawLocationReference invalid = new RawInvalidLocRef( location.getID(), retCode.getError(), location.getLocationType()); RawLocationReference rawLocRef = new RawCircleLocRef(location.getID(), gc, location.getRadius());
/** * {@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; } }
/** * {@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; } }
/** * Gets the nr of lr ps. * * @return the nr of lr ps * {@inheritDoc} */ @Override public final int getNrOfLRPs() { if (rawData == null || rawData.getLocationReferencePoints() == null) { return 0; } return rawData.getLocationReferencePoints().size(); }
/** * Checks for lr ps. * * @return true, if successful * {@inheritDoc} */ @Override public final boolean hasLRPs() { if (rawData == null || rawData.getLocationReferencePoints() == null) { return false; } return !rawData.getLocationReferencePoints().isEmpty(); }