@Override public Iterable<Location> getRawGeometry() { return asPolyLine(); }
@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)); if (this instanceof Edge) { tags.put("startNode", String.valueOf(((Edge) this).start().getIdentifier())); tags.put("endNode", String.valueOf(((Edge) this).end().getIdentifier())); } 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(getRawGeometry(), tags); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.feature(asPolyLine().asGeoJsonGeometry(), geoJsonProperties()); }
private void validatePolyLinePresent() { for (final LineItem lineItem : this.atlas.lineItems()) { if (lineItem.asPolyLine() == null) { throw new CoreException("{} {} is missing its PolyLine.", lineItem.getType(), lineItem.getIdentifier()); } } } }
private AtlasPrimitiveLineItem convert(final LineItem item) { return new AtlasPrimitiveLineItem(item.getIdentifier(), item.asPolyLine(), item.getTags()); }
final PolyLine objectAsPolyLine = object.asPolyLine(); if (object.getAtlas().areasIntersecting(object.bounds(), area -> (Validators.isOfType(area, LandUseTag.class, LandUseTag.MILITARY) || Validators.hasValuesFor(area, MilitaryTag.class)) && (object.intersects(area.asPolygon()) || area.asPolygon().fullyGeometricallyEncloses(objectAsPolyLine))) .iterator().hasNext()) for (final Relation relation : object.getAtlas().relationsWithEntitiesIntersecting( object.bounds(), relation -> (Validators.isOfType(relation, LandUseTag.class, LandUseTag.MILITARY) || Validators.hasValuesFor(relation, MilitaryTag.class)) if (object.intersects(relationPolygon) || relationPolygon.fullyGeometricallyEncloses(object.asPolyLine()))
@Override public JsonObject geoJsonProperties() { final JsonObject properties = super.geoJsonProperties(); properties.addProperty("startNode", start().getIdentifier()); properties.addProperty("endNode", end().getIdentifier()); return properties; }
@Override public boolean intersects(final GeometricSurface surface) { return surface.overlaps(asPolyLine()); }
@Override public String toWkt() { return this.asPolyLine().toWkt(); } }
/** * @return The length of this item */ public Distance length() { return asPolyLine().length(); }
@Override public byte[] toWkb() { return this.asPolyLine().toWkb(); }
@Override public Rectangle bounds() { return asPolyLine().bounds(); }
/** * @return the number of shape-points for this item, including start and end points. */ public int numberOfShapePoints() { return asPolyLine().size(); }
/** * @return The overall heading of the {@link PolyLine}: the heading between the start point and * the end point. */ public Optional<Heading> overallHeading() { return this.asPolyLine().overallHeading(); }
@Override protected double getValue(final T item) { return item.asPolyLine().length().asKilometers(); } }
private boolean lineItemCoversInitialShardBounds(final LineItem lineItem) { return this.policy.getInitialShardsBounds().overlaps(lineItem.asPolyLine()); }
private void processEntity(final AtlasEntity entity, final List<PolyLine> candidates, final List<Polygon> alreadyFormed) { if (entity instanceof Area) { // Easy alreadyFormed.add(((Area) entity).asPolygon()); } else if (entity instanceof LineItem) { // In case an Edge is an outer/inner, make sure to not double count it by looking at the // master edge only. if (!(entity instanceof Edge) || ((Edge) entity).isMasterEdge()) { candidates.add(((LineItem) entity).asPolyLine()); } } } }
public SnappedLocation snapTo(final LineItem other) { return this.getLocation().snapTo(other.asPolyLine()); }
/** * Check if this {@link LineItem} is closed. Closed is defined when the first {@link Location} * is the same as the last {@link Location}. * * @return {@code true} if it's closed. */ public boolean isClosed() { final PolyLine polyLine = asPolyLine(); return polyLine.first().equals(polyLine.last()); }
boolean lineItemCovered(final LineItem item) { final PolyLine polyLine = item.asPolyLine(); final MultiPolygon initialShardsBounds = this.policy.getInitialShardsBounds(); if (!this.policy.isExtendIndefinitely() && !initialShardsBounds.overlaps(polyLine)) { // 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.shardsIntersecting(polyLine); for (final Shard neededShard : neededShards) { if (!this.loadedShards.containsKey(neededShard)) { newPolyLine(polyLine, item); return false; } } return true; }