ERROR 6: GEOS support not enabled.
来源:互联网 发布:腾讯dns优化器手机版 编辑:程序博客网 时间:2024/06/02 23:08
要学习GEOS库,肯定绕不开地理方面的东西。如果需要判断的两个多边形或几何图形,不是自己创建的,而是来自shapefile文件,那就得将GEOS库和GDAL/OGR库结合使用了。实际上只需要OGR就行了,但OGR和GDAL是放在一起的。OGR库用来读取和输出shapefile(shp)文件,geos库用来判断空间关系。
需要注意的地方:OGR里面的几何图形类OGRGeometry和GOES里面的类Geometry基本上是一样的,函数也大体相同。OGRGeometry类里面也有类似于Disjoint(),Touches(),Overlaps()这样的函数。但是这些函数是花架子,没有GEOS库的支持是用不成的。如果只有OGR库而没有GEOS库,运行这些函数就会提示GEOS support not enabled.这样的错误,也得不到正确的结果。
在OGR的官方文档中,对Overlaps()函数有这样一句话描述:This method is built on the GEOS library, check it for the definition of the geometry operation. If OGR is built without the GEOS library, this method will always fail, issuing a CPLE_NotSupported error.
大致意思就是这个函数是建立在GEOS库的基础上,没有GEOS库的支持,这个函数运行会出错。
1、编译GEOS。参考http://www.cnblogs.com/denny402/p/4966558.html
2、编译GDAL. 参考http://www.cnblogs.com/sansan/p/3394636.html,注意要先编译GEOS,再编译GDAL,不然会提示找不到geos_c_i.lib这个库。
编译并设置好后,就可以开始代码测试了。
本例的数据及工具版本:
GDAL/OGR: 2.0.0
GEOS: 3.5.0
shp文件:中国国界和省界SHP文件 ,可点此下载
至于SHP文件的读取,可参考 http://www.cnblogs.com/denny402/p/4959867.html
测试代码:
#include "stdafx.h"#include <iostream>#include "ogrsf_frmts.h"using namespace std;int _tmain(int argc, _TCHAR* argv[]){ GDALAllRegister(); GDALDataset *poDS; CPLSetConfigOption("SHAPE_ENCODING",""); //解决中文乱码问题 //读取shp文件 poDS = (GDALDataset*) GDALOpenEx("d:/shp/province.shp", GDAL_OF_VECTOR, NULL, NULL, NULL ); if( poDS == NULL ) { printf( "Open failed.\n%s" ); exit( 1 ); } OGRLayer *poLayer; poLayer = poDS->GetLayer(0); //读取层 poLayer->ResetReading(); OGRFeature *poFeature1,*poFeature2,*poFeature3; poFeature1=poLayer->GetFeature(205); //四川省 poFeature2=poLayer->GetFeature(0); //黑龙江省 poFeature3=poLayer->GetFeature(66); //青海省 OGRGeometry *p1=poFeature1->GetGeometryRef(); OGRGeometry *p3=poFeature2->GetGeometryRef(); OGRGeometry *p2=poFeature3->GetGeometryRef(); cout<<p1->IsEmpty()<<endl //图形是否为空 <<p1->IsSimple()<<endl //是否是单个几何图形 <<p1->getGeometryType()<<endl //几何图形的类型,polygon返回3 <<p1->getGeometryName()<<endl //几何图形的名称 <<p1->getDimension()<<endl //图形的维度 <<p1->getCoordinateDimension()<<endl //坐标的维度 <<p1->getSpatialReference()<<endl; //空间参考 if(p2->Disjoint(p1)) cout<<"不相交"<<endl; else { if(p2->Touches(p1)) cout<<"接触"<<endl; else if(p2->Overlaps(p1)) cout<<"部分重叠"<<endl; else if(p2->Contains(p1)) cout<<"包含"<<endl; else cout<<"unknown"<<endl; } system("pause"); return 1;}
- ERROR 6: GEOS support not enabled.
- 503 5.5.1 Error: authentication not enabled
- # error "AES/PCLMUL instructions not enabled"
- vtigercrm 5.4 安装database utf 8 support not enabled
- error C1189: #error : MFC does not support
- error C1189: #error : MFC does not support
- Error: Debugging Failed Because Integrated Windows Authentication Is Not Enabled
- PHPExcel 错误Fatal error: ZipArchive library is not enabled
- configure: error: recommended PNG functions feature could not be enabled
- if there is a error "SSSE3 instruction set not enabled"
- GEOS
- xmmintrin.h:34:3: error: #error "SSE instruction set not enabled" 错误
- xmmintrin.h:34:3: error: #error "SSE instruction set not enabled" 错误
- Aggregation is not enabled.
- grails 保存数据库报:org.hibernate.AssertionFailure: getGeneratedKeys() support is not enabled
- mysql connect Error,Client does not support authentication protocol requested
- Error: Current license file does not support the EP2C5Q208C8 device
- (OK) error: code model kernel does not support PIC mode
- Java - 数据库(mysql - 4)
- 条码识别
- Google物联网操作系统协同框架Weave深度解析
- css3 为什么要加 -moz-box-shadow -webkit-box-shadow -o-box-shadow,直接用box-shadow不是都能识别吗?
- 更改kvm虚拟机磁盘大小
- ERROR 6: GEOS support not enabled.
- linux下搭建FTP服务
- 自定义可动画展开收缩View的实现
- swift 单例写法
- Collection集合总结
- ServletContext文件下载
- 一、H5全景图-朋友圈全景图-720°全景-VR -----工具使用
- centos Apcache 防DDOS攻击mod_evasive安装配置
- java socket 多线程的服务端与客户端的demo