/** * @param boundaries * A {@link Map} from country names to country boundaries in {@link MultiPolygon} * format * @return {@link CountryBoundaryMap} created from existing boundaries */ public static CountryBoundaryMap fromBoundaryMap(final Map<String, MultiPolygon> boundaries) { final CountryBoundaryMap map = new CountryBoundaryMap(Rectangle.MAXIMUM); boundaries.forEach((name, multiPolygon) -> map.addCountry(name, JTS_MULTI_POLYGON_TO_MULTI_POLYGON_CONVERTER.backwardConvert(multiPolygon))); return map; }
@Override public String convert(final MultiPolygon multiPolygon) { final com.vividsolutions.jts.geom.MultiPolygon geometry = new JtsMultiPolygonToMultiPolygonConverter() .backwardConvert(multiPolygon); return new WKTWriter().write(geometry); } }
@Override public byte[] convert(final MultiPolygon multiPolygon) { final Geometry geometry = new JtsMultiPolygonToMultiPolygonConverter() .backwardConvert(multiPolygon); final byte[] wkb = new WKBWriter().write(geometry); return wkb; } }
.backwardConvert(multiPolygon).toText());
.backwardConvert(multiPolygon); this.initializeGridIndex(area);
.backwardConvert(outline); complexBoundary.getCountries().forEach(isoCountry -> this .addCountry(isoCountry.getIso3CountryCode(), multiPolygon));
@Test public void testOnDemandIndexAndIndexFromFileViaArea() { // Generate grid index for the first time final CountryBoundaryMap firstMap = CountryBoundaryMap .fromPlainText(new InputStreamResource(CountryBoundaryMapTest.class .getResourceAsStream("MAF_AIA_osm_boundaries.txt.gz")) .withDecompressor(Decompressor.GZIP)); Assert.assertFalse(firstMap.hasGridIndex()); firstMap.initializeGridIndex( new JtsMultiPolygonToMultiPolygonConverter().backwardConvert(MultiPolygon.MAXIMUM)); Assert.assertTrue(firstMap.hasGridIndex()); // Read grid index from file final CountryBoundaryMap secondMap = CountryBoundaryMap .fromPlainText(new InputStreamResource(CountryBoundaryMapTest.class .getResourceAsStream("MAF_AIA_osm_boundaries_with_grid_index.txt.gz")) .withDecompressor(Decompressor.GZIP)); Assert.assertTrue(secondMap.hasGridIndex()); // Compare Assert.assertTrue(CountryBoundaryMapCompareCommand.areSTRtreesEqual(firstMap.getGridIndex(), secondMap.getGridIndex())); }