📄 ogrgeometry.cpp
字号:
* * Currently this is not implemented in a rigerous fashion, and generally * just tests whether the envelopes of the two features intersect. Eventually * this will be made rigerous. * * This function is the same as the CPP method OGRGeometry::Intersects. * * @param hGeom handle on the first geometry. * @param hOtherGeom handle on the other geometry to test against. * * @return TRUE if the geometries intersect, otherwise FALSE. */int OGR_G_Intersects( OGRGeometryH hGeom, OGRGeometryH hOtherGeom ){ return ((OGRGeometry *) hGeom)->Intersects( (OGRGeometry *) hOtherGeom );}int OGR_G_Intersect( OGRGeometryH hGeom, OGRGeometryH hOtherGeom ){ return ((OGRGeometry *) hGeom)->Intersects( (OGRGeometry *) hOtherGeom );}/************************************************************************//* transformTo() *//************************************************************************//** * Transform geometry to new spatial reference system. * * This method will transform the coordinates of a geometry from * their current spatial reference system to a new target spatial * reference system. Normally this means reprojecting the vectors, * but it could include datum shifts, and changes of units. * * This method will only work if the geometry already has an assigned * spatial reference system, and if it is transformable to the target * coordinate system. * * Because this method requires internal creation and initialization of an * OGRCoordinateTransformation object it is significantly more expensive to * use this method to transform many geometries than it is to create the * OGRCoordinateTransformation in advance, and call transform() with that * transformation. This method exists primarily for convenience when only * transforming a single geometry. * * This method is the same as the C function OGR_G_TransformTo(). * * @param poSR spatial reference system to transform to. * * @return OGRERR_NONE on success, or an error code. */OGRErr OGRGeometry::transformTo( OGRSpatialReference *poSR ){#ifdef DISABLE_OGRGEOM_TRANSFORM return OGRERR_FAILURE;#else OGRCoordinateTransformation *poCT; OGRErr eErr; if( getSpatialReference() == NULL || poSR == NULL ) return OGRERR_FAILURE; poCT = OGRCreateCoordinateTransformation( getSpatialReference(), poSR ); if( poCT == NULL ) return OGRERR_FAILURE; eErr = transform( poCT ); delete poCT; return eErr;#endif}/************************************************************************//* OGR_G_TransformTo() *//************************************************************************//** * Transform geometry to new spatial reference system. * * This function will transform the coordinates of a geometry from * their current spatial reference system to a new target spatial * reference system. Normally this means reprojecting the vectors, * but it could include datum shifts, and changes of units. * * This function will only work if the geometry already has an assigned * spatial reference system, and if it is transformable to the target * coordinate system. * * Because this function requires internal creation and initialization of an * OGRCoordinateTransformation object it is significantly more expensive to * use this function to transform many geometries than it is to create the * OGRCoordinateTransformation in advance, and call transform() with that * transformation. This function exists primarily for convenience when only * transforming a single geometry. * * This function is the same as the CPP method OGRGeometry::transformTo. * * @param hGeom handle on the geometry to apply the transform to. * @param hSRS handle on the spatial reference system to apply. * * @return OGRERR_NONE on success, or an error code. */OGRErr OGR_G_TransformTo( OGRGeometryH hGeom, OGRSpatialReferenceH hSRS ){ return ((OGRGeometry *) hGeom)->transformTo((OGRSpatialReference *) hSRS);}/** * \fn OGRErr OGRGeometry::transform( OGRCoordinateTransformation *poCT ); * * Apply arbitrary coordinate transformation to geometry. * * This method will transform the coordinates of a geometry from * their current spatial reference system to a new target spatial * reference system. Normally this means reprojecting the vectors, * but it could include datum shifts, and changes of units. * * Note that this method does not require that the geometry already * have a spatial reference system. It will be assumed that they can * be treated as having the source spatial reference system of the * OGRCoordinateTransformation object, and the actual SRS of the geometry * will be ignored. On successful completion the output OGRSpatialReference * of the OGRCoordinateTransformation will be assigned to the geometry. * * This method is the same as the C function OGR_G_Transform(). * * @param poCT the transformation to apply. * * @return OGRERR_NONE on success or an error code. *//************************************************************************//* OGR_G_Transform() *//************************************************************************//** * Apply arbitrary coordinate transformation to geometry. * * This function will transform the coordinates of a geometry from * their current spatial reference system to a new target spatial * reference system. Normally this means reprojecting the vectors, * but it could include datum shifts, and changes of units. * * Note that this function does not require that the geometry already * have a spatial reference system. It will be assumed that they can * be treated as having the source spatial reference system of the * OGRCoordinateTransformation object, and the actual SRS of the geometry * will be ignored. On successful completion the output OGRSpatialReference * of the OGRCoordinateTransformation will be assigned to the geometry. * * This function is the same as the CPP method OGRGeometry::transform. * * @param hGeom handle on the geometry to apply the transform to. * @param hTransform handle on the transformation to apply. * * @return OGRERR_NONE on success or an error code. */OGRErr OGR_G_Transform( OGRGeometryH hGeom, OGRCoordinateTransformationH hTransform ){ return ((OGRGeometry *) hGeom)->transform( (OGRCoordinateTransformation *) hTransform );}/** * \fn int OGRGeometry::getDimension() const; * * Get the dimension of this object. * * This method corresponds to the SFCOM IGeometry::GetDimension() method. * It indicates the dimension of the object, but does not indicate the * dimension of the underlying space (as indicated by * OGRGeometry::getCoordinateDimension()). * * This method is the same as the C function OGR_G_GetDimension(). * * @return 0 for points, 1 for lines and 2 for surfaces. *//************************************************************************//* OGR_G_GetDimension() *//************************************************************************//** * * Get the dimension of this geometry. * * This function corresponds to the SFCOM IGeometry::GetDimension() method. * It indicates the dimension of the geometry, but does not indicate the * dimension of the underlying space (as indicated by * OGR_G_GetCoordinateDimension() function). * * This function is the same as the CPP method OGRGeometry::getDimension(). * * @param hGeom handle on the geometry to get the dimension from. * @return 0 for points, 1 for lines and 2 for surfaces. */int OGR_G_GetDimension( OGRGeometryH hGeom ){ return ((OGRGeometry *) hGeom)->getDimension();}/************************************************************************//* getCoordinateDimension() *//************************************************************************//** * Get the dimension of the coordinates in this object. * * This method corresponds to the SFCOM IGeometry::GetDimension() method. * * This method is the same as the C function OGR_G_GetCoordinateDimension(). * * @return in practice this always returns 2 indicating that coordinates are * specified within a two dimensional space. */int OGRGeometry::getCoordinateDimension() const{ return nCoordDimension;}/************************************************************************//* OGR_G_GetCoordinateDimension() *//************************************************************************//** * * Get the dimension of the coordinates in this geometry. * * This function corresponds to the SFCOM IGeometry::GetDimension() method. * * This function is the same as the CPP method * OGRGeometry::getCoordinateDimension(). * * @param hGeom handle on the geometry to get the dimension of the * coordinates from. * @return in practice this always returns 2 indicating that coordinates are * specified within a two dimensional space. */int OGR_G_GetCoordinateDimension( OGRGeometryH hGeom ){ return ((OGRGeometry *) hGeom)->getCoordinateDimension();}/************************************************************************//* setCoordinateDimension() *//************************************************************************//** * Set the coordinate dimension. * * This method sets the explicit coordinate dimension. Setting the coordinate * dimension of a geometry to 2 should zero out any existing Z values. Setting * the dimension of a geometry collection will not necessarily affect the * children geometries. * * @param nNewDimension New coordinate dimension value, either 2 or 3. */void OGRGeometry::setCoordinateDimension( int nNewDimension ){ nCoordDimension = nNewDimension;}/************************************************************************//* OGR_G_SetCoordinateDimension() *//************************************************************************/void OGR_G_SetCoordinateDimension( OGRGeometryH hGeom, int nNewDimension){ ((OGRGeometry *) hGeom)->setCoordinateDimension( nNewDimension );}/** * \fn OGRBoolean OGRGeometry::IsEmpty() const; * * Returns TRUE (non-zero) if the object has no points. Normally this * returns FALSE except between when an object is instantiated and points * have been assigned. * * This method relates to the SFCOM IGeometry::IsEmpty() method. * * NOTE: This method is hardcoded to return FALSE at this time. * * @return TRUE if object is empty, otherwise FALSE. *//** * \fn OGRBoolean OGRGeometry::IsSimple() const; * * Returns TRUE if the geometry is simple. * * Returns TRUE if the geometry has no anomalous geometric points, such * as self intersection or self tangency. The description of each * instantiable geometric class will include the specific conditions that * cause an instance of that class to be classified as not simple. * * This method relates to the SFCOM IGeometry::IsSimple() method. * * NOTE: This method is hardcoded to return TRUE at this time. * * @return TRUE if object is simple, otherwise FALSE. *//** * \fn int OGRGeometry::Equals( OGRGeometry *poOtherGeom ) const; * * Returns two if two geometries are equivalent. * * This method is the same as the C function OGR_G_Equal(). * * @return TRUE if equivalent or FALSE otherwise. */// Backward compatibility method.int OGRGeometry::Equal( OGRGeometry *poOtherGeom ) const{ return Equals( poOtherGeom );}/************************************************************************//* OGR_G_Equals() *//************************************************************************//** * Returns two if two geometries are equivalent. * * This function is the same as the CPP method OGRGeometry::Equals() method. * * @param hGeom handle on the first geometry. * @param hOther handle on the other geometry to test against. * @return TRUE if equivalent or FALSE otherwise. */int OGR_G_Equals( OGRGeometryH hGeom, OGRGeometryH hOther ){ return ((OGRGeometry *) hGeom)->Equals( (OGRGeometry *) hOther );}int OGR_G_Equal( OGRGeometryH hGeom, OGRGeometryH hOther ){ return ((OGRGeometry *) hGeom)->Equals( (OGRGeometry *) hOther );}/** * \fn int OGRGeometry::WkbSize() const; * * Returns size of related binary representation. * * This method returns the exact number of bytes required to hold the * well known binary representation of this geometry object. Its computation * may be slightly expensive for complex geometries. * * This method relates to the SFCOM IWks::WkbSize() method. * * This method is the same as the C function OGR_G_WkbSize(). * * @return size of binary representation in bytes. *//************************************************************************//* OGR_G_WkbSize() *//************************************************************************//** * Returns size of related binary representation. * * This function returns the exact number of bytes required to hold the * well known binary representation of this geometry object. Its computation * may be slightly expensive for complex geometries. * * This function relates to the SFCOM IWks::WkbSize() method. * * This function is the same as the CPP method OGRGeometry::WkbSize(). * * @param hGeom handle on the geometry to get the binary size from. * @return size of binary representation in bytes. */int OGR_G_WkbSize( OGRGeometryH hGeom ){ return ((OGRGeometry *) hGeom)->WkbSize();}/** * \fn void OGRGeometry::getEnvelope(OGREnvelope *psEnvelope) const; * * Computes and returns the bounding envelope for this geometry in the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -