Java Code Examples for com.vividsolutions.jts.geom.Geometry#geometryChanged()
The following examples show how to use
com.vividsolutions.jts.geom.Geometry#geometryChanged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void translate(final Geometry geom) { if (gisToAbsoluteTranslation != null) { geom.apply(gisToAbsoluteTranslation); geom.geometryChanged(); } }
Example 2
Source File: WorldProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void inverseTranslate(final Geometry geom) { if (absoluteToGisTranslation != null) { geom.apply(absoluteToGisTranslation); geom.geometryChanged(); } }
Example 3
Source File: WorldProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void convertUnit(Geometry geom) { if (otherUnitToMeter != null) { geom.apply(otherUnitToMeter); geom.geometryChanged(); } }
Example 4
Source File: WorldProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void inverseConvertUnit(Geometry geom) { if (meterToOtherUnit != null) { geom.apply(meterToOtherUnit); geom.geometryChanged(); } }
Example 5
Source File: SimpleScalingProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public Geometry transform(Geometry geom) { if (scaling != null) { geom.apply(scaling); geom.geometryChanged(); } return geom; }
Example 6
Source File: SimpleScalingProjection.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public Geometry inverseTransform(Geometry geom) { if (inverseScaling != null) { geom.apply(inverseScaling); geom.geometryChanged(); } return geom; }
Example 7
Source File: GamaGeoJsonFile.java From gama with GNU General Public License v3.0 | 5 votes |
public void readShapes(final IScope scope) { final IList<IShape> list = getBuffer(); int size = 0; final SimpleFeatureCollection fc = getFeatureCollection(scope); if (fc == null) { return; } final Envelope3D env = Envelope3D.of(fc.getBounds()); size = fc.size(); int index = 0; computeProjection(scope, env); try (SimpleFeatureIterator reader = fc.features()) { while (reader.hasNext()) { index++; if (index % 20 == 0) { scope.getGui().getStatus(scope).setSubStatusCompletion(index / (double) size); } final SimpleFeature feature = reader.next(); Geometry g = (Geometry) feature.getDefaultGeometry(); if (g != null && !g.isEmpty() /* Fix for Issue 725 && 677 */ ) { g = gis.transform(g); if (!with3D) { g.apply(ZERO_Z); g.geometryChanged(); } list.add(new GamaGisGeometry(g, feature)); } else if (g == null) { // See Issue 725 GAMA.reportError(scope, GamaRuntimeException .warning("GamaGeoJsonFile.fillBuffer; geometry could not be added as it is " + "nil: " + feature.getIdentifier(), scope), false); } } } if (size > list.size()) { GAMA.reportError(scope, GamaRuntimeException.warning("Problem with file " + getFile(scope) + ": only " + list.size() + " of the " + size + " geometries could be added", scope), false); } }
Example 8
Source File: GeometryUtils.java From gama with GNU General Public License v3.0 | 5 votes |
private static IList<IShape> filterGeoms(final GeometryCollection geom, final Geometry clip, final double sizeTol, final boolean approxClipping) { if (geom == null) { return null; } final double elevation = getContourCoordinates(clip).averageZ(); final boolean setZ = elevation != 0.0; final IList<IShape> result = GamaListFactory.create(Types.GEOMETRY); final Geometry bufferClip = sizeTol != 0.0 ? clip.buffer(sizeTol, 5, 0) : clip; final PreparedGeometry buffered = PREPARED_GEOMETRY_FACTORY.create(bufferClip); final Envelope3D env = Envelope3D.of(buffered.getGeometry()); try { for (int i = 0; i < geom.getNumGeometries(); i++) { final Geometry gg = geom.getGeometryN(i); if (!clip.covers(gg.getCentroid())) continue; final Coordinate[] coord = gg.getCoordinates(); boolean cond = env.covers(gg.getCentroid().getCoordinate()); cond = cond && (approxClipping ? buffered.covers(gg.getCentroid()) && buffered.covers(GEOMETRY_FACTORY.createPoint(coord[0])) && buffered.covers(GEOMETRY_FACTORY.createPoint(coord[1])) && buffered.covers(GEOMETRY_FACTORY.createPoint(coord[2])) : bufferClip.covers(gg)); if (cond) { if (setZ) { final ICoordinates cc = getContourCoordinates(gg); cc.setAllZ(elevation); gg.geometryChanged(); } result.add(new GamaShape(gg)); } } } finally { env.dispose(); } /* * applyToInnerGeometries(geom, (gg) -> { final ICoordinates cc = getContourCoordinates(gg); if * (cc.isCoveredBy(env) && buffered.covers(gg)) { * * } }); */ return result; }
Example 9
Source File: GeometryUtils.java From gama with GNU General Public License v3.0 | 5 votes |
public static void translate(final Geometry geometry, final double dx, final double dy, final double dz) { geometry.apply((final Coordinate p) -> { p.x += dx; p.y += dy; p.z += dz; }); geometry.geometryChanged(); }
Example 10
Source File: VectorLayerComponentImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
private void drawFeature(PdfContext context, ClientMapInfo map, InternalFeature f) { FeatureStyleInfo style = f.getStyleInfo(); // Color, transparency, dash Color fillColor = context.getColor(style.getFillColor(), style.getFillOpacity()); Color strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity()); float[] dashArray = context.getDashArray(style.getDashArray()); // check if the feature is selected if (selectedFeatures.contains(f.getId())) { if (f.getGeometry() instanceof MultiPolygon || f.getGeometry() instanceof Polygon) { style = mergeStyle(style, map.getPolygonSelectStyle()); fillColor = context.getColor(style.getFillColor(), style.getFillOpacity()); strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity()); } else if (f.getGeometry() instanceof MultiLineString || f.getGeometry() instanceof LineString) { style = mergeStyle(style, map.getLineSelectStyle()); strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity()); } else if (f.getGeometry() instanceof MultiPoint || f.getGeometry() instanceof Point) { style = mergeStyle(style, map.getPointSelectStyle()); strokeColor = context.getColor(style.getStrokeColor(), style.getStrokeOpacity()); } } float lineWidth = style.getStrokeWidth(); SymbolInfo symbol = null; if (f.getGeometry() instanceof MultiPoint || f.getGeometry() instanceof Point) { symbol = style.getSymbol(); } // clone geometry Geometry geometry = (Geometry) f.getGeometry().clone(); // transform to user space geometry.apply(new MapToUserFilter()); // notify geometry change !!! geometry.geometryChanged(); // now draw context.drawGeometry(geometry, symbol, fillColor, strokeColor, lineWidth, dashArray, getSize()); }
Example 11
Source File: GamaShapeFile.java From gama with GNU General Public License v3.0 | 4 votes |
protected void readShapes(final IScope scope) { scope.getGui().getStatus(scope).beginSubStatus("Reading file " + getName(scope)); ShapefileDataStore store = null; final File file = getFile(scope); final IList list = getBuffer(); int size = 0; try { store = getDataStore(file.toURI().toURL()); final ContentFeatureSource source = store.getFeatureSource(); final Envelope3D env = Envelope3D.of(source.getBounds()); size = source.getCount(Query.ALL); int index = 0; computeProjection(scope, env); try (FeatureReader reader = store.getFeatureReader()) { while (reader.hasNext()) { index++; if (index % 20 == 0) { scope.getGui().getStatus(scope).setSubStatusCompletion(index / (double) size); } final Feature feature = reader.next(); Geometry g = (Geometry) feature.getDefaultGeometryProperty().getValue(); if (g != null && !g.isEmpty() /* Fix for Issue 725 && 677 */ ) { if (!with3D && !g.isValid()) { g = GeometryUtils.cleanGeometry(g); } g = gis.transform(g); if (!with3D) { g.apply(ZERO_Z); g.geometryChanged(); } g = multiPolygonManagement(g); GamaGisGeometry gt = new GamaGisGeometry(g, feature); if (gt.getInnerGeometry() != null) list.add(gt); } else if (g == null) { // See Issue 725 GAMA.reportError(scope, GamaRuntimeException .warning("GamaShapeFile.fillBuffer; geometry could not be added as it is " + "nil: " + feature.getIdentifier(), scope), false); } } } } catch (final IOException e) { throw GamaRuntimeException.create(e, scope); } finally { if (store != null) { store.dispose(); } scope.getGui().getStatus(scope).endSubStatus("Reading file " + getName(scope)); } if (size > list.size()) { GAMA.reportError(scope, GamaRuntimeException.warning("Problem with file " + getFile(scope) + ": only " + list.size() + " of the " + size + " geometries could be added", scope), false); } }
Example 12
Source File: GeometryUtils.java From gama with GNU General Public License v3.0 | 4 votes |
public static void rotate(final Geometry geometry, final GamaPoint center, final AxisAngle rotation) { if (rotation == null) { return; } final Rotation3D r = new Rotation3D.CenteredOn(rotation, center); geometry.apply(r); geometry.geometryChanged(); }
Example 13
Source File: ShapeExecuter.java From gama with GNU General Public License v3.0 | 4 votes |
@Override Rectangle2D executeOn(final IScope scope, final IGraphics gr, final DrawingData data) throws GamaRuntimeException { final IShape shape = constantShape == null ? asGeometry(scope, item.value(scope), false) : constantShape; if (shape == null) { return null; } final DrawingAttributes attributes = computeAttributes(scope, data, shape); Geometry gg = shape.getInnerGeometry(); if (gg == null) { return null; } final ICoordinates ic = getContourCoordinates(gg); ic.ensureClockwiseness(); // If the graphics is 2D, we pre-translate and pre-rotate the geometry if (gr.is2D()) { ic.getCenter(center); rotate(gg, center, attributes.getRotation()); final GamaPoint location = attributes.getLocation(); if (location != null) { if (gg.getNumPoints() == 1) { gg = GEOMETRY_FACTORY.createPoint(location); } else { translate(gg, center, location); } } gg.geometryChanged(); } if (hasArrows) { final Geometry withArrows = addArrows(scope, gg, !attributes.isEmpty()); if (withArrows != gg) { gg = withArrows; attributes.setType(IShape.Type.NULL); } } final Geometry withTorus = addToroidalParts(scope, gg); if (withTorus != gg) { gg = withTorus; attributes.setType(IShape.Type.NULL); } // XXX EXPERIMENTAL See Issue #1521 if (GamaPreferences.Displays.DISPLAY_ONLY_VISIBLE.getValue() && !scope.getExperiment().isHeadless()) { final Envelope3D e = shape.getEnvelope(); try { final Envelope visible = gr.getVisibleRegion(); if (visible != null) { if (!visible.intersects(e)) { return null; } // XXX EXPERIMENTAL } } finally { e.dispose(); } } // The textures are computed as well in advance addTextures(scope, attributes); // And we ask the IGraphics object to draw the shape return gr.drawShape(gg, attributes); }