我试图将MultiPoint几何的每个点与LineString的起点和终点进行比较,下面是我的代码:
第一种方法:
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...
}
第二种方法:我创建了一个具有当前几何的点然后我比较
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...
}
有第二种方法的输出:
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
在迭代1中,我们看到lineString的startPoint等于迭代1中的当前点,因此程序继续并传递到下一次迭代
在迭代2中,我们也看到lineString的EndPoint等于此迭代中的当前点但是程序没有继续
我不知道为什么当点的坐标相同时程序没有继续执行!!!
为什么在第一次迭代中它没关系然后在第二次迭代中它不会!
我使用GEOS C ++ 3.4
任何想法,请帮忙吗?当我转到GEOS 3.6版时,会解决问题吗?