/** * @return The underlying {@link PolyLine}, which will not have the end {@link Location} equal * to the start {@link Location}. i.e. the area will not be closed. */ @Override public Iterable<Location> getRawGeometry() { return asPolygon(); }
private AtlasPrimitiveArea convert(final Area area) { return new AtlasPrimitiveArea(area.getIdentifier(), area.asPolygon(), area.getTags()); }
@Override protected Optional<CheckFlag> flag(final AtlasObject object) { final Area building = (Area) object; final Iterable<Edge> intersectingEdges = Iterables.filter(building.getAtlas() .edgesIntersecting(building.bounds(), this.intersectsCoreWayInvalidly(building)), ignoreTags()); final CheckFlag flag = new CheckFlag(getTaskIdentifier(building)); flag.addObject(building); this.handleIntersections(intersectingEdges, flag, building); return flag.getPolyLines().size() > 1 ? Optional.of(flag) : Optional.empty(); }
@Override public String toString() { return "[Area: id=" + this.getIdentifier() + ", polygon=" + this.asPolygon() + ", " + tagString() + "]"; }
@Override protected boolean isCounted(final Area item) { return item.containsValue("natural", NATURAL_MATCHES) && (item.containsValue("water", WATER_MATCHES) || item.tag("water") == null) || item.containsValue("landuse", LANDUSE_MATCHES); }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Area: id=" + this.getIdentifier() + ", polygon=" + this.asPolygon() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
public static CompleteArea from(final Area area) { return new CompleteArea(area.getIdentifier(), area.asPolygon(), area.getTags(), area.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
@Override public LocationIterableProperties toGeoJsonBuildingBlock() { final Map<String, String> tags = getTags(); tags.put("identifier", String.valueOf(getIdentifier())); tags.put("osmIdentifier", String.valueOf(getOsmIdentifier())); tags.put("itemType", String.valueOf(getType())); final Optional<String> shardName = getAtlas().metaData().getShardName(); shardName.ifPresent(shard -> tags.put("shard", shard)); final StringList parentRelations = new StringList(); this.relations().forEach(relation -> { final RelationMember member = relation.members().get(getIdentifier(), getType()); parentRelations.add(member.getRelationIdentifier() + "-" + member.getRole()); }); if (!parentRelations.isEmpty()) { tags.put("parentRelations", parentRelations.join(", ")); } return new GeoJsonBuilder.LocationIterableProperties(getClosedGeometry(), tags); }
final Polygon aoiPolygon = aoi.asPolygon(); final Rectangle aoiBounds = aoiPolygon.bounds(); boolean hasOverlap = false; area -> area.getIdentifier() != aoi.getIdentifier() && !this.isFlagged(area.getIdentifier()) && area.intersects(aoiPolygon) && aoiFiltersTest(area))) .collectToSet(); area.asPolygon()) >= this.minimumIntersect && aoiFiltersTest(object, area)) area.getOsmIdentifier())); this.markAsFlagged(area.getIdentifier()); hasOverlap = true;
public static CompleteArea shallowFrom(final Area area) { return new CompleteArea(area.getIdentifier()).withInitialBounds(area.asPolygon().bounds()); }
final Area area = deserialized.area(areaIdentifier); logger.info("Got Area {}", areaIdentifier); final Surface surface = area.asPolygon().surface(); logger.info("Got Area surface {}", surface); final Map<String, String> areaTags = area.getTags(); logger.info("Got Area tags {}", areaTags); logger.info("{}", areaTags);
final Area source = atlas.area(27); final CompleteArea result = CompleteArea.shallowFrom(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); result.withPolygon(Polygon.TEST_BUILDING); Assert.assertEquals(Rectangle.forLocated(source.bounds(), Polygon.TEST_BUILDING), result.bounds()); final Map<String, String> tags = Maps.hashMap("key", "value"); result.withTags(tags); Assert.assertEquals(tags, result.getTags()); result.withRelationIdentifiers(source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) Assert.assertEquals(Rectangle.forLocated(source.bounds(), Polygon.SILICON_VALLEY), result.bounds());
@Test public void testArea() { final Area area1 = this.atlas.area(45); final Area area2 = this.atlas.area(54); logger.trace(area1.toString()); logger.trace(area2.toString()); Assert.assertTrue(area1.asPolygon().intersects(area2.asPolygon())); Assert.assertEquals(Location.TEST_6, area1.asPolygon().intersections(area2.asPolygon()).iterator().next()); Assert.assertEquals("golf_course", area1.getTags().get("leisure")); Assert.assertEquals("grassland", area1.getTags().get("natural")); Assert.assertFalse(AerowayTag.get(area1).isPresent()); Assert.assertEquals(LeisureTag.GOLF_COURSE, LeisureTag.get(area1).orElseThrow(CoreException.supplier("No tag"))); Assert.assertEquals(NaturalTag.GRASSLAND, NaturalTag.get(area1).orElseThrow(CoreException.supplier("No tag"))); Assert.assertFalse(WaterTag.get(area1).isPresent()); Assert.assertFalse(AerowayTag.get(area2).isPresent()); Assert.assertEquals(LeisureTag.SWIMMING_POOL, LeisureTag.get(area2).orElseThrow(CoreException.supplier("No tag"))); Assert.assertEquals(SportTag.SWIMMING, SportTag.get(area2).orElseThrow(CoreException.supplier("No tag"))); Assert.assertFalse(NaturalTag.get(area2).isPresent()); Assert.assertFalse(WaterTag.get(area2).isPresent()); }
/** * Generates a unique identifier tuple as a {@link String} for given {@link Area}s identifiers * * @param area * First {@link Area} instance * @param otherArea * Another {@link Area} instance * @return A unique identifier tuple in {@link String} */ private static String getIdentifierTuple(final Area area, final Area otherArea) { return area.getIdentifier() < otherArea.getIdentifier() ? String.format(UNIQUE_IDENTIFIER_FORMAT, area.getIdentifier(), otherArea.getIdentifier()) : String.format(UNIQUE_IDENTIFIER_FORMAT, otherArea.getIdentifier(), area.getIdentifier()); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.feature(asPolygon().asGeoJsonGeometry(), geoJsonProperties()); }
final Iterable<Location> edge1RawGeometry = atlas.area(1).getRawGeometry(); logger.info("Edge 1 raw geometry {}", edge1RawGeometry); final Iterable<Location> edge1ClosedGeometry = atlas.area(1).getClosedGeometry(); logger.info("Edge 1 closed geometry {}", Lists.newArrayList(edge1ClosedGeometry)); final Iterable<Location> edge2RawGeometry = atlas.area(2).getRawGeometry(); logger.info("Edge 2 raw geometry {}", edge2RawGeometry); final Iterable<Location> edge2ClosedGeometry = atlas.area(2).getClosedGeometry(); logger.info("Edge 2 closed geometry {}", Lists.newArrayList(edge2ClosedGeometry));
@Override public Set<Relation> relations() { return subArea().relations().stream() .map(relation -> new DynamicRelation(dynamicAtlas(), relation.getIdentifier())) .collect(Collectors.toSet()); }
@Override public Map<String, String> getTags() { return subArea().getTags(); }
building.getOsmIdentifier(), edge.getOsmIdentifier())); knownIntersections.add(edge); final Optional<Edge> reversedEdge = edge.reversed();