/** * {@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 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; } }
BinaryReturnCode.INVALID_BINARY_DATA, e); RawPolygonLocRef rawLocRef = new RawPolygonLocRef(id, cornersCoords); return rawLocRef;