Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将坐标与GEOS C和x2B进行比较+;失败_C++_Gdal_Geos_Ogr - Fatal编程技术网

C++ 将坐标与GEOS C和x2B进行比较+;失败

C++ 将坐标与GEOS C和x2B进行比较+;失败,c++,gdal,geos,ogr,C++,Gdal,Geos,Ogr,我试图将多点几何体的每个点与LineString的起点和终点进行比较,下面是我的代码: 第一种方法: geos::geom::LineString* ptLine = dynamic_cast<LineString*>( ptCurrentGeomIntersection ); for( int iCurrentPoint = 0; iCurrentPoint < ptGeom->getNumPoints(); iCurrentPoint++ ){ if( ptLi

我试图将多点几何体的每个点与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...
}
在迭代1中,我们看到lineString的起始点等于迭代1中的当前点,因此程序将继续并传递到下一个迭代

在迭代2中,我们还看到lineString的端点与该迭代中的当前点相等,但程序没有继续

我不知道为什么程序没有执行继续当点的坐标是相同的

为什么在第一次迭代中它是好的,而在第二次迭代中它不会

我使用GEOSC++ 3.4


有什么想法,有什么帮助吗?当我转到GEOS的3.6版时,这会解决问题吗?

我不理解
几何体::equals
的文档,但我观察到
有一个
equalsExact
函数,它具有公差。我认为你需要用非零容忍度来代替。非常感谢你的回答,但它不起作用。事实上,我在验证相等点后尝试进行的处理:我检索坐标序列中不相等的点,然后创建一个LineString,当我发布序列中点的坐标和直线的坐标时,我注意到添加的点在序列和线串中没有相同的坐标。下面有输出:。下面有输出(仅端坐标序列):30199.36089161384 1064013.1404002085,还有输出(仅限LineString的端点)在创建坐标序列为30199.3608916138 1064013.1404002085的LineString后,出现了一些奇怪的情况。请提供帮助,我尝试了许多方法,但都没有得到结果!作为一般规则,比较等式。浮点数学不精确。尝试使用距离:if(ptLine->getStartPoint()->距离(ptGeom->getGeometryN(ICcurrentPoint))
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