/** * Constructs an {@link AtlasDataSource} with bounding box. Only {@link Atlas} data within the * bounding box will be loaded * * @param sparkContext * spark context as key-value pairs to use as context * @param configuration * the {@link Configuration} * @param boundingBox * a {@link Rectangle} boundary */ public AtlasDataSource(final Map<String, String> sparkContext, final Configuration configuration, final Rectangle boundingBox) { this(sparkContext, configuration, MultiPolygon.forPolygon(boundingBox)); }
public DynamicAtlasPolicy(final Function<Shard, Optional<Atlas>> atlasFetcher, final Sharding sharding, final Polygon shapeCoveringInitialShards, final Polygon maximumBounds) { this.initialShards = new HashSet<>(); this.shapeCoveringInitialShards = Optional .of(MultiPolygon.forPolygon(shapeCoveringInitialShards)); sharding.shards(shapeCoveringInitialShards).forEach(this.initialShards::add); this.atlasFetcher = atlasFetcher; this.maximumBounds = maximumBounds; this.sharding = sharding; }
final Clip clip = MultiPolygon.forPolygon(Rectangle.MAXIMUM).clip(allCountries, ClipType.NOT); final MultiPolygon result = clip.getClipMultiPolygon();
@Test public void testEmptyClip() { final Polygon outer = Polygon.wkt( "POLYGON ((-122.05576 37.332439, -122.009566 37.36531, -122.031007 37.390535, -122.05576 37.332439))"); final MultiPolygon clipping = MultiPolygon.forPolygon(outer); final MultiPolygon clipped = SUBJECT_MULTIPOLYGON.clip(clipping, ClipType.AND) .getClipMultiPolygon(); Assert.assertTrue(clipped.isEmpty()); }
MultiPolygon multiPolygon = MultiPolygon.forPolygon(Rectangle.MAXIMUM); if (boundaryFile != null) multiPolygon = MultiPolygon.forPolygon(bound);
return MultiPolygon.forPolygon(((Area) entity).asPolygon());
@Test public void testRawAtlasCreationWithBoundingBox() { final String path = RawAtlasGeneratorTest.class.getResource("9-433-268.osm.pbf").getPath(); final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(path), MultiPolygon.forPolygon(Location.forWkt("POINT (124.9721500 -8.9466200)").bounds() .expand(Distance.meters(100)))); final Atlas atlas = rawAtlasGenerator.build(); // Verify Atlas Entities assertBasicRawAtlasPrinciples(atlas); Assert.assertEquals(1361, atlas.numberOfPoints()); Assert.assertEquals(25, atlas.numberOfLines()); Assert.assertEquals(0, atlas.numberOfRelations()); }
@Test public void testSurface() { final Rectangle rectangle = Rectangle.TEST_RECTANGLE; Assert.assertEquals(rectangle.surface(), MultiPolygon.forPolygon(rectangle).surface()); final MultiPolygon tilted = MultiPolygon.forPolygon(new Polygon(rectangle.lowerLeft(), new Location(rectangle.upperLeft().getLatitude(), Longitude.degrees(rectangle.upperLeft().getLongitude().asDegrees() + 0.1)), new Location(rectangle.upperRight().getLatitude(), Longitude.degrees(rectangle.upperRight().getLongitude().asDegrees() + 0.1)), rectangle.lowerRight())); Assert.assertEquals(rectangle.surface(), tilted.surface()); }
Location.forString("33.99632001003,66.22558525085"), Location.forString("34.15102284294,66.22764518738")); final MultiPolygon boundary = MultiPolygon.forPolygon(fakePolygon); boundaries.put(afghanistan, boundary); final CountryBoundaryMap countryBoundaryMap = CountryBoundaryMap
Location.forString("37.34051308677875,-122.02124118804932"), Location.forString("37.3447096829136,-122.03505992889404")); this.countryShape1 = MultiPolygon.forPolygon(polygon1); this.countryShape2 = MultiPolygon.forPolygon(polygon2); final Map<String, MultiPolygon> boundaries = new HashMap<>(); boundaries.put(COUNTRY_1_NAME, this.countryShape1);