27 #include "../dataaccess/dataset/DataSet.h" 28 #include "../dataaccess/dataset/ObjectId.h" 29 #include "../dataaccess/utils/Utils.h" 30 #include "../datatype/SimpleData.h" 31 #include "../geometry/Coord2D.h" 32 #include "../geometry/Envelope.h" 33 #include "../geometry/GeometryCollection.h" 34 #include "../geometry/GeometryProperty.h" 35 #include "../geometry/LineString.h" 36 #include "../geometry/MultiLineString.h" 37 #include "../geometry/MultiPoint.h" 38 #include "../geometry/MultiPolygon.h" 39 #include "../geometry/Point.h" 40 #include "../geometry/Polygon.h" 41 #include "../geometry/Utils.h" 42 #include "../srs/Config.h" 49 #include <boost/uuid/random_generator.hpp> 50 #include <boost/uuid/uuid_io.hpp> 73 Feature* f = RepositoryManager::getInstance().getFeature(layer->
getId(), env, srid);
82 std::unique_ptr<const te::map::LayerSchema> schema(layer->
getSchema());
84 if(!schema->hasGeom())
87 std::vector<std::string> oidPropertyNames;
95 if(dataset.get() ==
nullptr)
105 while(dataset->moveNext())
107 std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->getName()));
109 if (g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
130 GetLines(dynamic_cast<te::gm::GeometryCollection*>(geom), lines);
134 GetLines(dynamic_cast<te::gm::Polygon*>(geom), lines);
138 GetLines(dynamic_cast<te::gm::LineString*>(geom), lines);
158 std::vector<te::gm::Curve*>& rings = p->
getRings();
160 for (std::size_t i = 0; i < rings.size(); ++i)
161 GetLines(dynamic_cast<te::gm::LineString*>(rings[i]), lines);
173 assert(index.
m_line < lines.size());
177 assert(index.
m_pos < l->getNPoints());
182 l->setPoint(l->getNPoints() - 1, x, y);
185 l->setPoint(index.
m_pos, x, y);
191 assert(index.
m_line < lines.size());
198 for (std::size_t i = 0; i < currentLine->getNPoints(); ++i)
201 if (i == index.
m_pos)
204 if (
IsSpecialRingVertex(currentLine, index) && ((i == 0) || (i == currentLine->getNPoints() - 1)))
207 newLine->
setPoint(pos, currentLine->getX(i), currentLine->getY(i));
211 if (currentLine->isClosed())
215 *currentLine = *newLine;
228 currentLine->getGeomTypeId(), currentLine->getSRID());
231 for (std::size_t i = 0; i < currentLine->getNPoints(); ++i)
233 newLine->
setPoint(pos, currentLine->getX(i), currentLine->getY(i));
236 if (i == index.
m_pos)
244 *currentLine = *newLine;
258 for (std::size_t i = 0; i < lines.size(); ++i)
262 for (std::size_t j = 0; j < line->
getNPoints() - 1; ++j)
266 segment->setPoint(0, line->
getX(j), line->
getY(j));
267 segment->setPoint(1, line->
getX(j + 1), line->
getY(j + 1));
269 if (geometryFromEnvelope->intersects(segment.get()))
309 point->
setX(point->
getX() + deltax);
310 point->
setY(point->
getY() + deltay);
321 std::vector<te::gm::LineString*> lines;
324 for (std::size_t i = 0; i < lines.size(); ++i)
329 for (std::size_t j = 0; j < l->
getNPoints(); ++j)
347 return sqrt(((c1.
x - c2.
x) * (c1.
x - c2.
x)) + ((c1.
y - c2.
y) * (c1.
y - c2.
y)));
355 std::vector<te::gm::LineString*> lines;
360 for (std::size_t i = 0; i < lines.size(); ++i)
363 for (std::size_t j = 0; j < line->
getNPoints(); ++j)
399 if (SnapManager::getInstance().search(coord, srid, result) ==
false)
413 static boost::uuids::basic_random_generator<boost::mt19937> gen;
415 boost::uuids::uuid u = gen();
416 std::string
id = boost::uuids::to_string(u);
432 std::unique_ptr<te::da::DataSetType>
dt = layer->getSchema();
543 if (newGeom ==
nullptr)
549 if (newGeom->getSRID() == layer->getSRID())
553 newGeom->transform(layer->getSRID());
568 std::vector<te::gm::LineString*> lines;
573 for (std::size_t i = 0; i < lines.size(); ++i)
576 alfa = (4.*std::atan(1.)*angle) / 180.;
581 for (std::size_t count = 0; count < lines[i]->size(); count++)
585 std::unique_ptr<te::gm::Point> curPoint = l->
getPointN(count);
587 x = curPoint->getX() -
dx;
588 y = curPoint->getY() - dy;
590 xr = x * std::cos(alfa) - y * std::sin(alfa);
591 yr = x * std::sin(alfa) + y * std::cos(alfa);
593 l->
setPoint(count, xr + dx, yr + dy);
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
virtual const std::string & getId() const
It returns the layer id.
MultiPolygon is a MultiSurface whose elements are Polygons.
SimpleData< std::string, STRING_TYPE > String
std::vector< Curve * > & getRings()
It returns the polygon rings.
TEEDITEXPORT void MoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index, const double &x, const double &y)
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
TEEDITEXPORT te::da::ObjectId * GenerateId()
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
This is the base class for layers.
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
static te::dt::Date dx(2010, 12, 31)
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
TEEDITEXPORT void Rotate(te::gm::Geometry *geom, double angle)
virtual Visibility getVisibility() const
It returns the layer visibility.
TEEDITEXPORT te::gm::Geometry * Convert2LayerGeomType(const te::map::AbstractLayerPtr &layer, te::gm::Geometry *geom, int srid)
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
void addValue(te::dt::AbstractData *data)
It adds a property value to uniquely identify a data set element.
This is a singleton for managing edit repositories.
This class represents a geographic feature.
TEEDITEXPORT void GetCoordinates(te::gm::Geometry *geom, std::vector< te::gm::Coord2D > &coords)
virtual bool isValid() const =0
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
bool isClosed() const
It returns true if the curve is closed (startPoint = endPoint).
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
te::gm::GeometryCollection * gc
te::gm::Coord2D getCentroid() const _NOEXCEPT_OP(false)
It will get the centroid of the input geometries.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
TEEDITEXPORT void RemoveVertex(std::vector< te::gm::LineString * > &lines, const VertexIndex &index)
MultiPoint is a GeometryCollection whose elements are restricted to points.
LineString is a curve with linear interpolation between points.
void setOperationTypeId(const te::edit::OperationType ¤tOperationType)
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
void ObjectId()
ObjectId example.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
This class represents an unique id for a data set element.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid)
TEEDITEXPORT double GetDistance(const te::gm::Coord2D &c1, const te::gm::Coord2D &c2)
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Utility functions for the data access module.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
This is a singleton for managing geometries snap.
TEEDITEXPORT void MoveGeometry(te::gm::Geometry *geom, const double &deltax, const double &deltay)
TEEDITEXPORT void AddVertex(std::vector< te::gm::LineString * > &lines, const double &x, const double &y, const te::gm::Envelope &env, int srid)
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double getX() const
It returns the x-coordinate.
TEEDITEXPORT void TrySnap(te::gm::Coord2D &coord, int srid)
virtual std::unique_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const =0
It gets the dataset identified by the layer name.
void setX(const double &x)
It sets the Point x-coordinate value.
void add(Geometry *g)
It adds the geometry into the collection.
TEEDITEXPORT void GetLines(te::gm::Geometry *geom, std::vector< te::gm::LineString * > &lines)
virtual void setSRID(int srid) _NOEXCEPT_OP(true)=0
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
TEEDITEXPORT bool IsSpecialRingVertex(te::gm::LineString *l, const VertexIndex &index)
TEDATAACCESSEXPORT void GetOIDPropertyNames(const DataSetType *type, std::vector< std::string > &pnames)
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
A template for atomic data types (integers, floats, strings and others).
void setY(const double &y)
It sets the Point y-coordinate value.
It is a collection of other geometric objects.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
const double & getX() const
It returns the Point x-coordinate value.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
TEEDITEXPORT VertexIndex FindSegment(std::vector< te::gm::LineString * > &lines, const te::gm::Envelope &env, int srid)