@Override public Iterable<Location> getRawGeometry() { return getLocation(); }
@Override public boolean intersects(final GeometricSurface surface) { return surface.fullyGeometricallyEncloses(getLocation()); }
@Override public String toWkt() { return this.getLocation().toWkt(); } }
@Override public byte[] toWkb() { return this.getLocation().toWkb(); }
/** * Default constructor * * @param locationItem * the {@link LocationItem} to flag */ public FlaggedPoint(final LocationItem locationItem) { this.locationItem = locationItem; this.point = locationItem.getLocation(); this.properties = initProperties(locationItem); }
@Override public Rectangle bounds() { return getLocation().bounds(); }
private boolean locationItemCoversInitialShardBounds(final LocationItem locationItem) { return this.policy.getInitialShardsBounds() .fullyGeometricallyEncloses(locationItem.getLocation()); }
public SnappedLocation snapTo(final LineItem other) { return this.getLocation().snapTo(other.asPolyLine()); }
public SnappedLocation snapTo(final Area other) { return this.getLocation().snapTo(other.asPolygon()); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.feature(getLocation().asGeoJsonGeometry(), geoJsonProperties()); }
protected void validateLocationPresent() { for (final LocationItem locationItem : this.atlas.locationItems()) { if (locationItem.getLocation() == null) { throw new CoreException("{} {} is missing a Location.", locationItem.getType(), locationItem.getIdentifier()); } } } }
boolean locationItemCovered(final LocationItem item) { final Location location = item.getLocation(); final MultiPolygon initialShardsBounds = this.policy.getInitialShardsBounds(); if (!this.policy.isExtendIndefinitely() && !initialShardsBounds.fullyGeometricallyEncloses(location)) { // If the policy is to not extend indefinitely, then assume that the loading is not // necessary. return true; } final Iterable<? extends Shard> neededShards = this.sharding.shardsCovering(location); for (final Shard neededShard : neededShards) { if (!this.loadedShards.containsKey(neededShard)) { newLocation(location, item); return false; } } return true; }
@Override public GeometryPrintable convert(final AtlasEntity source) { GeometryPrintable result = null; if (source instanceof Area) { result = ((Area) source).asPolygon(); } else if (source instanceof LineItem) { result = ((LineItem) source).asPolyLine(); } else if (source instanceof LocationItem) { result = ((LocationItem) source).getLocation(); } else { // Relation result = ((Relation) source).bounds(); } if (result == null) { result = source.bounds(); } return result; } }
@Override public boolean multiPolygonEntityIntersecting(final MultiPolygon multiPolygon, final AtlasEntity entity) { if (entity instanceof LineItem) { return multiPolygon.overlaps(((LineItem) entity).asPolyLine()); } if (entity instanceof LocationItem) { return multiPolygon .fullyGeometricallyEncloses(((LocationItem) entity).getLocation()); } if (entity instanceof Area) { return multiPolygon.overlaps(((Area) entity).asPolygon()); } if (entity instanceof Relation) { return ((Relation) entity).members().stream().map(RelationMember::getEntity) .anyMatch(relationEntity -> this .multiPolygonEntityIntersecting(multiPolygon, relationEntity)); } else { return false; } }
private AtlasPrimitiveLocationItem convert(final LocationItem item) { return new AtlasPrimitiveLocationItem(item.getIdentifier(), item.getLocation(), item.getTags()); }
final Location location = this.getLocation(); tags.put("latitude", String.valueOf(location.getLatitude().asDm7())); tags.put("longitude", String.valueOf(location.getLongitude().asDm7()));
@Override public boolean polygonEntityIntersecting(final Polygon polygon, final AtlasEntity entity) { if (entity instanceof LineItem) { return polygon.fullyGeometricallyEncloses(((LineItem) entity).asPolyLine()); } if (entity instanceof LocationItem) { return polygon.fullyGeometricallyEncloses(((LocationItem) entity).getLocation()); } if (entity instanceof Area) { return polygon.fullyGeometricallyEncloses(((Area) entity).asPolygon()); } if (entity instanceof Relation) { return ((Relation) entity).members().stream().map(RelationMember::getEntity) .anyMatch(relationEntity -> this.polygonEntityIntersecting(polygon, relationEntity)); } else { return false; } }
@Override public boolean multiPolygonEntityIntersecting(final MultiPolygon multiPolygon, final AtlasEntity entity) { if (entity instanceof LineItem) { return multiPolygon.fullyGeometricallyEncloses(((LineItem) entity).asPolyLine()); } if (entity instanceof LocationItem) { return multiPolygon .fullyGeometricallyEncloses(((LocationItem) entity).getLocation()); } if (entity instanceof Area) { return multiPolygon.fullyGeometricallyEncloses(((Area) entity).asPolygon()); } if (entity instanceof Relation) { return ((Relation) entity).members().stream().map(RelationMember::getEntity) .anyMatch(relationEntity -> this .multiPolygonEntityIntersecting(multiPolygon, relationEntity)); } else { return false; } }
@Override public boolean geometricSurfaceEntityIntersecting(final GeometricSurface geometricSurface, final AtlasEntity entity) { if (entity instanceof LineItem) { return geometricSurface .fullyGeometricallyEncloses(((LineItem) entity).asPolyLine()); } if (entity instanceof LocationItem) { return geometricSurface .fullyGeometricallyEncloses(((LocationItem) entity).getLocation()); } if (entity instanceof Area) { return geometricSurface.fullyGeometricallyEncloses(((Area) entity).asPolygon()); } if (entity instanceof Relation) { return ((Relation) entity).members().stream().map(RelationMember::getEntity) .anyMatch(relationEntity -> this.geometricSurfaceEntityIntersecting( geometricSurface, relationEntity)); } else { return false; } } };
@Test public void testMergeLocations() { final FeatureChange featureChange1 = new FeatureChange(ChangeType.ADD, new CompletePoint(123L, Location.COLOSSEUM, null, null)); final FeatureChange featureChange2 = new FeatureChange(ChangeType.ADD, new CompletePoint(123L, Location.COLOSSEUM, null, null)); Assert.assertEquals(Location.COLOSSEUM, ((LocationItem) featureChange1.merge(featureChange2).getReference()).getLocation()); }