/** * Edit the input {@link Geometry} with the given edit operation. * Clients will create subclasses of {@link GeometryEditorOperation} or * {@link CoordinateOperation} to perform required modifications. * * @param geometry the Geometry to edit * @param operation the edit operation to carry out * @return a new {@link Geometry} which is the result of the editing */ Geometry* GeometryEditor::edit(const Geometry *geometry, GeometryEditorOperation *operation) { // if client did not supply a GeometryFactory, use the one from the input Geometry if (factory == NULL) factory=geometry->getFactory(); if ((typeid(*geometry)==typeid(GeometryCollection)) || (typeid(*geometry)==typeid(MultiPoint)) || (typeid(*geometry)==typeid(MultiPolygon)) || (typeid(*geometry)==typeid(MultiLineString))) { return editGeometryCollection((const GeometryCollection*) geometry, operation); } if (typeid(*geometry)==typeid(Polygon)) { return editPolygon((Polygon*) geometry, operation); } if (typeid(*geometry)==typeid(Point)) { return operation->edit(geometry, factory); } if (typeid(*geometry)==typeid(LineString) || typeid(*geometry)==typeid(LinearRing)) { return operation->edit(geometry, factory); } Assert::shouldNeverReachHere("Unsupported Geometry classes should be caught in the GeometryEditorOperation."); return NULL; }
/** * Edit the input {@link Geometry} with the given edit operation. * Clients will create subclasses of GeometryEditorOperation or * CoordinateOperation to perform required modifications. * * @param geometry the Geometry to edit * @param operation the edit operation to carry out * @return a new {@link Geometry} which is the result of the editing */ Geometry* GeometryEditor::edit(const Geometry *geometry, GeometryEditorOperation *operation) { // if client did not supply a GeometryFactory, use the one from the input Geometry if (factory == NULL) factory=geometry->getFactory(); if ( const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geometry) ) { return editGeometryCollection(gc, operation); } if ( const Polygon *p = dynamic_cast<const Polygon*>(geometry) ) { return editPolygon(p, operation); } if ( dynamic_cast<const Point*>(geometry) ) { return operation->edit(geometry, factory); } if ( dynamic_cast<const LineString*>(geometry) ) { return operation->edit(geometry, factory); } // Unsupported Geometry classes should be caught in the GeometryEditorOperation. assert(!"SHOULD NEVER GET HERE"); return NULL; }