/** * {@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 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; } }
RawGridLocRef rawLocRef = new RawGridLocRef(id, lowerLeft, upperRight, ncols.getDimension(), nrows.getDimension()); if (binData != null) {