郴州网站设计,千图网免费素材图库官网,购物网站建设包括哪些,北京建站管理系统价格OGRLineString class ogr_geometry.h
OGRLineString 类是 OGR 库中的一个几何对象类#xff0c;用于表示线段或折线。它由多个坐标点组成#xff0c;并且在坐标点之间形成线段。OGRLineString 可以包含 2D、3D 或 3DM 坐标点#xff0c;其中 M 表示额外…OGRLineString class ogr_geometry.h
OGRLineString 类是 OGR 库中的一个几何对象类用于表示线段或折线。它由多个坐标点组成并且在坐标点之间形成线段。OGRLineString 可以包含 2D、3D 或 3DM 坐标点其中 M 表示额外的度量值例如时间或速度 Public Functions OGRLineString()
创建一个空线串 OGRLineStringconst OGRLineString other)
复制构造函数 OGRLineString operatorconst OGRLineString other)
赋值运算符 clone
virtual OGRLineString *clone const override
创建此对象的副本
OGRLineString lineString;// 添加两个坐标点构成线段
lineString.addPoint(0.0, 0.0);
lineString.addPoint(10.0, 10.0);// 克隆 OGRLineString 对象
OGRLineString* clonedLineString lineString.clone();CurveToLine
virtual OGRLineString *CurveToLinedouble dfMaxAngleStepSizeDegrees 0 const char *const *papszOptions nullptr const override
从曲线几何返回线串
参数: dfMaxAngleStepSizeDegrees -- 沿弧的最大步长以度为单位使用默认设置为零。 papszOptions -- 选项作为以 null 结尾的字符串列表或 NULL。
返回: 近似曲线的线串
OGRLineString lineString;// Add points to the lineString (this could be a curve)
lineString.addPoint(0, 0);
lineString.addPoint(1, 1);
lineString.addPoint(2, 0);// Convert curve to line
OGRLineString* convertedLine lineString.CurveToLine();// Output the converted lines points
for (int i 0; i convertedLine-getNumPoints(); i) {double x, y;convertedLine-getPoint(i, x, y);std::cout Point i : ( x , y ) std::endl;
}// Release memory
delete convertedLine; getCurveGeometry
virtual OGRGeometry *getCurveGeometryconst char *const *papszOptions nullptr const override
返回此几何图形的曲线版本
参数:
papszOptions -- 选项作为以 null 结尾的字符串列表。暂时未使用。必须设置为 NULL。
返回: 新的几何图形
// 创建一个线性曲线对象OGRLineString linearRing;linearRing.addPoint(0, 0);linearRing.addPoint(1, 0);linearRing.addPoint(1, 1);linearRing.addPoint(0, 1);linearRing.addPoint(0, 0);// 获取线性曲线的几何对象OGRGeometry* curveGeometry linearRing.getCurveGeometry();// 输出几何对象的类型if (curveGeometry ! nullptr) {OGRwkbGeometryType geomType curveGeometry-getGeometryType();const char* typeName OGRGeometryTypeToName(geomType);printf(Curve geometry type: %s\n, typeName);// 释放内存OGRGeometryFactory::destroyGeometry(curveGeometry);} else {printf(Failed to get curve geometry.\n);} get_Area
virtual double get_Area() const override
获取闭合曲线的面积
返回: 要素的面积以使用的空间参考系统的平方单位表示
// 创建一个多边形对象OGRLinearRing ring;ring.addPoint(0, 0);ring.addPoint(1, 0);ring.addPoint(1, 1);ring.addPoint(0, 1);ring.addPoint(0, 0);OGRPolygon polygon;polygon.addRing(ring);// 获取多边形对象的面积double area polygon.get_Area();// 输出面积printf(Polygon area: %f\n, area); getGeometryType
virtual OGRwkbGeometryType getGeometryType const override
返回:
几何类型类型 // 创建一个点对象OGRPoint point(10.0, 20.0);// 获取点对象的几何类型OGRwkbGeometryType geomType point.getGeometryType();// 输出几何类型switch (geomType) {case wkbPoint:printf(Geometry Type: Point\n);break;case wkbLineString:printf(Geometry Type: LineString\n);break;case wkbPolygon:printf(Geometry Type: Polygon\n);break;// 更多几何类型的处理...default:printf(Unknown Geometry Type\n);break;} getGeometryName
Virtual const char *getGeometryName const override
获取几何类型的 WKT 名称
返回: 用于此几何类型的名称采用众所周知的文本格式。返回的指针指向静态内部字符串不应修改或释放
// 创建一个点对象OGRPoint point(10.0, 20.0);// 获取几何对象的名称const char* geometryName point.getGeometryName();// 输出几何对象的名称printf(Geometry Name: %s\n, geometryName); isClockwise
virtual int isClockwise const override
如果环具有顺时针绕组或小于 2 磅则返回 TRUE
返回: 如果顺时针为真否则为假
/ 创建一个多边形对象OGRLinearRing ring;ring.addPoint(0, 0);ring.addPoint(0, 1);ring.addPoint(1, 1);ring.addPoint(1, 0);ring.addPoint(0, 0);OGRPolygon polygon;polygon.addRing(ring);// 判断多边形顶点排列方向int clockwise polygon.isClockwise();// 输出判断结果if (clockwise 0) {printf(Polygon is clockwise.\n);} else if (clockwise 0) {printf(Polygon is counterclockwise.\n);} else {printf(Vertices are collinear or not a valid polygon.\n);}