I m trying to compare every point of MultiPoint geometry with start point and end point of LineString , there is my code below:
First method:
geos::geom::LineString* ptLine = dynamic_cast<LineString*>( ptCurrentGeomIntersection );
for( int iCurrentPoint = 0; iCurrentPoint < ptGeom->getNumPoints(); iCurrentPoint++ ){
if( ptLine->getStartPoint()->equals( ptGeom->getGeometryN( iCurrentPoint ) ) )
continue;
else if ( ptLine->getEndPoint()->equals( ptGeom->getGeometryN( iCurrentPoint ) ) )
continue;
//other treatement...
}
Second method: I have create a point with current geometry then i compare
geos::geom::LineString* ptLine = dynamic_cast<LineString*>( ptCurrentGeomIntersection );
for( int iCurrentPoint = 0; iCurrentPoint < ptGeom->getNumPoints(); iCurrentPoint++ ){
Point* ptCurrentPointToAdd = m_ptFactory->createPoint( *ptGeom->getGeometryN( iCurrentPoint )->getCoordinate() );
if( ptLine->getStartPoint()->equals( ptCurrentPointToAdd ) )
continue;
if ( ptLine->getEndPoint()->equals( ptCurrentPointToAdd ) )
continue;
//other treatement...
}
there is output of second method:
LINESTRING (1768.8442503851 1010570.2425701290, 4228.5112185504
1012209.0468547827, 6688.1781867156 1013847.8511394364, 9147.8451548809
1015486.6554240901, 11607.5121230462 1017125.4597087437, 14067.1790912114
1018764.2639933976, 16526.8460593767 1020403.0682780512, 17667.8781414151
1024149.1601604699, 18597.0195615059 1028233.8708438184, 19526.1609815966
1032318.5815271670, 20455.3024016874 1036403.2922105156, 21384.4438217781
1040488.0028938639, 22313.5852418688 1044572.7135772125, 23242.7266619596
1048657.4242605611, 24171.8680820503 1052742.1349439095, 25101.0095021411
1056826.8456272581,26030.1509222318 1060911.5563106067, 28501.8267239067
1062557.9895967811, 30199.3608916138 1064013.1404002085)
MULTIPOINT (1768.8442503851 1010570.2425701290, 30199.3608916138 1064013.1404002085)
iteration 1:
POINT (1768.8442503851 1010570.2425701290) // startPoint of lineString
POINT (30199.3608916138 1064013.1404002085)//EndPoint of lineString
POINT (1768.8442503851 1010570.2425701290) //Current point of Multipoint geometry
iteration 2:
POINT (1768.8442503851 1010570.2425701290) // startPoint of lineString
POINT (30199.3608916138 1064013.1404002085)//EndPoint of lineString
POINT (30199.3608916138 1064013.1404002085)//Current point of Multipoint geometry
In the iteration 1 , we see that startPoint of lineString is equal to the current point in iteration 1 , so the program do continue and pass to the next iteration
In iteration 2 , we see also the EndPoint of lineString is equal to the current point in this iteration BUT the program did not continue
I don't know why the program did not execute continue when the coordinates of the points are the same !!!
why in the first iteration it's ok then in the second iteration it will not!
I use GEOS C++ 3.4
Any idea, any help please ? is that when I pass to version 3.6 of GEOS, will solve the problem?