⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrlinestring.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** * $Id: ogrlinestring.cpp,v 1.38 2003/06/09 13:48:54 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  The OGRLineString geometry class. * Author:   Frank Warmerdam, warmerda@home.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * $Log: ogrlinestring.cpp,v $ * Revision 1.38  2003/06/09 13:48:54  warmerda * added DB2 V7.2 byte order hack * * Revision 1.37  2003/05/28 19:16:43  warmerda * fixed up argument names and stuff for docs * * Revision 1.36  2003/03/07 21:28:56  warmerda * support 0x8000 style 3D WKB flags * * Revision 1.35  2003/01/06 17:43:13  warmerda * fixed buffer sizing problem for 3D geometries * * Revision 1.34  2003/01/06 16:18:40  warmerda * getEnvlope() crash fix if there are no points * * Revision 1.33  2002/09/11 13:47:17  warmerda * preliminary set of fixes for 3D WKB enum * * Revision 1.32  2002/08/19 14:11:35  warmerda * correct second setPoints() method properly. * * Revision 1.31  2002/08/19 03:24:51  warmerda * Fixed serious bug with 3D points in setPoints() methods. * * Revision 1.30  2002/07/15 13:31:07  warmerda * patch from Graeme for exportToWkb() with swapping code * * Revision 1.29  2002/05/02 19:45:36  warmerda * added flattenTo2D() method * * Revision 1.28  2002/04/17 21:43:09  warmerda * Free z array in descructor. * * Revision 1.27  2002/04/08 17:50:09  warmerda * Ensure Equal operator tests first vertex too. * * Revision 1.26  2002/03/05 14:25:14  warmerda * expand tabs * * Revision 1.25  2002/02/22 22:24:08  warmerda * clarify setPoints code * * Revision 1.24  2001/11/14 14:44:06  warmerda * fixed problem with WKT translation * * Revision 1.23  2001/11/01 17:20:33  warmerda * added DISABLE_OGRGEOM_TRANSFORM macro * * Revision 1.22  2001/11/01 17:01:28  warmerda * pass output buffer into OGRMakeWktCoordinate * * Revision 1.21  2001/09/21 16:24:20  warmerda * added transform() and transformTo() methods * * Revision 1.20  2001/07/19 18:25:07  warmerda * expanded tabs * * Revision 1.19  2001/07/18 05:03:05  warmerda * added CPL_CVSID * * Revision 1.18  2001/05/24 18:06:06  warmerda * fixed comment * * Revision 1.17  2001/01/19 21:10:47  warmerda * replaced tabs * * Revision 1.16  2000/01/26 21:20:47  warmerda * fixed crash assigning 2D points when already 3D * * Revision 1.15  1999/12/23 14:47:16  warmerda * improved 2D/3D handling to avoid 3D unless padfZ != 0.0 * * Revision 1.14  1999/11/18 19:02:19  warmerda * expanded tabs * * Revision 1.13  1999/11/17 19:38:22  warmerda * Further performance tweaks to exportToWkt(). * * Revision 1.12  1999/11/04 18:31:32  warmerda * Improved efficiency of exportToWkt() for large line strings. * * Revision 1.11  1999/09/13 14:34:07  warmerda * updated to use wkbZ of 0x8000 instead of 0x80000000 * * Revision 1.10  1999/09/13 02:27:33  warmerda * incorporated limited 2.5d support * * Revision 1.9  1999/07/27 00:48:11  warmerda * Added Equal() support * * Revision 1.8  1999/07/06 21:36:47  warmerda * tenatively added getEnvelope() and Intersect() * * Revision 1.7  1999/06/25 20:44:43  warmerda * implemented assignSpatialReference, carry properly * * Revision 1.6  1999/05/31 20:43:34  warmerda * added empty(), and another setPoints() * * Revision 1.5  1999/05/31 15:01:59  warmerda * OGRCurve now an abstract base class with essentially no implementation. * Everything moved down to OGRLineString where it belongs.  Also documented * classes. * * Revision 1.4  1999/05/23 05:34:40  warmerda * added support for clone(), multipolygons and geometry collections * * Revision 1.3  1999/05/20 14:35:44  warmerda * added support for well known text format * * Revision 1.2  1999/03/30 21:21:43  warmerda * added linearring/polygon support * * Revision 1.1  1999/03/29 21:21:10  warmerda * New * */#include "ogr_geometry.h"#include "ogr_p.h"#include <assert.h>CPL_CVSID("$Id: ogrlinestring.cpp,v 1.38 2003/06/09 13:48:54 warmerda Exp $");/************************************************************************//*                           OGRLineString()                            *//************************************************************************//** * Create an empty line string. */OGRLineString::OGRLineString(){    nPointCount = 0;    paoPoints = NULL;    padfZ = NULL;}/************************************************************************//*                           ~OGRLineString()                           *//************************************************************************/OGRLineString::~OGRLineString(){    if( paoPoints != NULL )        OGRFree( paoPoints );    if( padfZ != NULL )        OGRFree( padfZ );}/************************************************************************//*                          getGeometryType()                           *//************************************************************************/OGRwkbGeometryType OGRLineString::getGeometryType(){    if( getCoordinateDimension() == 3 )        return wkbLineString25D;    else        return wkbLineString;}/************************************************************************//*                            flattenTo2D()                             *//************************************************************************/void OGRLineString::flattenTo2D(){    Make2D();}/************************************************************************//*                          getGeometryName()                           *//************************************************************************/const char * OGRLineString::getGeometryName(){    return "LINESTRING";}/************************************************************************//*                               clone()                                *//************************************************************************/OGRGeometry *OGRLineString::clone(){    OGRLineString       *poNewLineString;    poNewLineString = new OGRLineString();    poNewLineString->assignSpatialReference( getSpatialReference() );    poNewLineString->setPoints( nPointCount, paoPoints, padfZ );    // notdef: not 3D    return poNewLineString;}/************************************************************************//*                               empty()                                *//************************************************************************/void OGRLineString::empty(){    setNumPoints( 0 );}/************************************************************************//*                            getDimension()                            *//************************************************************************/int OGRLineString::getDimension(){    return 1;}/************************************************************************//*                       getCoordinateDimension()                       *//************************************************************************/int OGRLineString::getCoordinateDimension(){    if( padfZ != NULL )        return 3;    else        return 2;}/************************************************************************//*                              WkbSize()                               *//*                                                                      *//*      Return the size of this object in well known binary             *//*      representation including the byte order, and type information.  *//************************************************************************/int OGRLineString::WkbSize(){    return 5 + 4 + 8 * nPointCount * getCoordinateDimension();}/************************************************************************//*                               Make2D()                               *//************************************************************************/void OGRLineString::Make2D(){    if( padfZ != NULL )    {        OGRFree( padfZ );        padfZ = NULL;    }}/************************************************************************//*                               Make3D()                               *//************************************************************************/void OGRLineString::Make3D(){    if( padfZ == NULL )    {        if( nPointCount == 0 )            padfZ = (double *) OGRCalloc(sizeof(double),1);        else            padfZ = (double *) OGRCalloc(sizeof(double),nPointCount);    }}/************************************************************************//*                              getPoint()                              *//************************************************************************//** * Fetch a point in line string. * * This method relates to the SFCOM ILineString::get_Point() method. * * @param i the vertex to fetch, from 0 to getNumPoints()-1. * @param poPoint a point to initialize with the fetched point. */void    OGRLineString::getPoint( int i, OGRPoint * poPoint ){    assert( i >= 0 );    assert( i < nPointCount );    assert( poPoint != NULL );    poPoint->setX( paoPoints[i].x );    poPoint->setY( paoPoints[i].y );    if( getCoordinateDimension() == 3 )        poPoint->setZ( padfZ[i] );}/************************************************************************//*                                getZ()                                *//************************************************************************/double OGRLineString::getZ( int i ){    if( padfZ != NULL && i >= 0 && i < nPointCount )        return( padfZ[i] );    else        return 0.0;}/************************************************************************//*                            setNumPoints()                            *//************************************************************************//** * Set number of points in geometry. * * This method primary exists to preset the number of points in a linestring * geometry before setPoint() is used to assign them to avoid reallocating * the array larger with each call to addPoint().  * * This method has no SFCOM analog. * * @param nNewPointCount the new number of points for geometry. */void OGRLineString::setNumPoints( int nNewPointCount )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -