@Override public Iterable<Location> getRawGeometry() { return asPolyLine(); }
@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 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()); } } } }
private boolean lineItemCoversInitialShardBounds(final LineItem lineItem) { return this.policy.getInitialShardsBounds().overlaps(lineItem.asPolyLine()); }
public SnappedLocation snapTo(final LineItem other) { return this.getLocation().snapTo(other.asPolyLine()); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.feature(asPolyLine().asGeoJsonGeometry(), geoJsonProperties()); }
/** * 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()); }
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()); } } } }
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; }
@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 AtlasPrimitiveLineItem convert(final LineItem item) { return new AtlasPrimitiveLineItem(item.getIdentifier(), item.asPolyLine(), item.getTags()); }
@Test public void testMergePolyLines() { final PolyLine result = new PolyLine(Location.COLOSSEUM, Location.EIFFEL_TOWER); final FeatureChange featureChange1 = new FeatureChange(ChangeType.ADD, new CompleteLine(123L, result, null, null)); final FeatureChange featureChange2 = new FeatureChange(ChangeType.ADD, new CompleteLine(123L, result, null, null)); Assert.assertEquals(result, ((LineItem) featureChange1.merge(featureChange2).getReference()).asPolyLine()); }