/*public*/ std::auto_ptr<Coordinate::Vect> LineStringSnapper::snapTo(const geom::Coordinate::ConstVect& snapPts) { geom::CoordinateList coordList(srcPts); snapVertices(coordList, snapPts); snapSegments(coordList, snapPts); return coordList.toCoordinateArray(); }
bool MapFacade::snapVertices(const size_t snapTo) { return snapVertices(VertexToBrushesMap(), snapTo); }
void VertexSnapper::snap() { qDebug("VertexSnapper::snap: ENTERING SNAP"); for ( unsigned int i = 0; i < subGeometry.size(); i++ ) { // find close features from the reference layer // vectors of coordinates of close Geometries std::vector<double> closeCoordX; std::vector<double> closeCoordY; qDebug("VertexSnapper::snap: Vectors with coordinates created"); for ( unsigned int j = 0; j < refGeometry.size(); j++) { bool close = isClose( subGeometry[i].getGEOSGeom(), refGeometry[j].getGEOSGeom() ); qDebug("VertexSnapper::snap: isClose checked."); if (close) { // add close coordinates //closeCoord->add( refGeometry[j].getGEOSGeom()->getCoordinates(), false, true );//(*ref_it).getGEOSGeom()->getCoordinates(), false, true ); // get points from geometry //GEOSGeometry* points = GEOSGeom_extractUniquePoints( refGeometry[j].getGEOSGeom() ); const GEOSCoordSequence *coords = GEOSGeom_getCoordSeq( refGeometry[j].getGEOSGeom() ); // NOTE: Only linestring or points is possible //GEOSCoordSequence *coords = GEOSCoordSeq_clone( s ); qDebug("VertexSnapper::snap: GEOSCoordSequence cloned from refGeometry"); // get number of points unsigned int cSize; GEOSCoordSeq_getSize( coords, &cSize ); // add x and y coordinates to the vectors for ( unsigned int k = 0; k < cSize; k++ ) { double x, y; GEOSCoordSeq_getX( coords, k, &x ); GEOSCoordSeq_getY( coords, k, &y ); closeCoordX.push_back(x); closeCoordY.push_back(y); qDebug("VertexSnapper::snap: Close coordinates x, y added to vector"); } //GEOSCoordSeq_destroy(coords); } } // create sequence with close points int dim = GEOSGeom_getDimensions( refGeometry[0].getGEOSGeom() ); GEOSCoordSequence *closeCoord = GEOSCoordSeq_create( closeCoordX.size(), dim ); qDebug("VertexSnapper::snap: GEOSCoordSequence closeCoord created"); for( unsigned int l = 0; l < closeCoordX.size(); l++) { GEOSCoordSeq_setX(closeCoord, l, closeCoordX[l]); GEOSCoordSeq_setY(closeCoord, l, closeCoordY[l]); } // snap vertex snapVertices( &subGeometry[i], closeCoord); newGeometry.push_back( subGeometry[i] ); GEOSCoordSeq_destroy(closeCoord); } } // void VertexSnapper::snap()