📄 ogrlinestring.cpp
字号:
/****************************************************************************** * $Id: ogrlinestring.cpp,v 1.62 2006/11/18 20:04:08 mloskot Exp $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: The OGRLineString geometry class. * Author: Frank Warmerdam, warmerdam@pobox.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.62 2006/11/18 20:04:08 mloskot * Changed type of buffer size testers from size_t to int. * * Revision 1.61 2006/10/03 09:23:55 dron * Removed too verbosive debug output. * * Revision 1.60 2006/09/21 16:51:10 osemykin * nBytesAvailable fixes as in OGRLinearRing::importFromWkb() * * Revision 1.59 2006/09/05 12:14:28 mloskot * Fixed nBytesAvailable tests inside importFromWkb() * in OGRLineString and OGRLinearRing classes. * * Revision 1.58 2006/07/15 09:12:44 mloskot * New fixes related to Bug 1195. Recent fixes had minor bugs. * NOTE: OGR autotests are failing so they may need some changes (in progress). * * Revision 1.57 2006/07/14 20:30:25 mloskot * Fixed new issue related to Bug 1195. Fixed Bug 313. * * Revision 1.56 2006/07/12 11:53:27 mloskot * Fixed Bug 1195 and Bug 1230. * * Revision 1.55 2006/07/07 15:09:12 fwarmerdam * improve handling of empty linearrings and polygons in aggregates * * Revision 1.54 2006/03/31 17:57:32 fwarmerdam * header updates * * Revision 1.53 2006/01/29 15:06:34 fwarmerdam * documented getX, getY, getZ and getNumPoints accessors * * Revision 1.52 2005/12/02 11:06:51 osemykin * added const for OGRLineString::getPoints(...) * * Revision 1.51 2005/09/21 07:45:53 osemykin * Fixed getPoints() for support Z coordinate NULL buffer * * Revision 1.50 2005/09/17 12:11:30 osemykin * added OGRLineString::getPoints * * Revision 1.49 2005/07/22 19:28:56 fwarmerdam * reserve extra space for WKT encoding of weird numbers * * Revision 1.48 2005/07/20 01:43:51 fwarmerdam * upgraded OGR geometry dimension handling * * Revision 1.47 2005/07/12 17:34:00 fwarmerdam * updated to produce proper empty syntax and consume either * * Revision 1.46 2005/03/25 06:31:12 fwarmerdam * added addSubLineString * * Revision 1.45 2005/02/22 12:38:01 fwarmerdam * rename Equal/Intersect to Equals/Intersects * * Revision 1.44 2004/02/22 10:09:16 dron * Fix compirison casting problems in Equal() method. * * Revision 1.43 2004/02/21 15:36:14 warmerda * const correctness updates for geometry: bug 289 * * Revision 1.42 2004/02/20 18:03:36 warmerda * Applied new Value() implementation to deal with duplicate points. * http://bugzilla.remotesensing.org/show_bug.cgi?id=384 * * Revision 1.41 2004/01/16 21:57:16 warmerda * fixed up EMPTY support * * Revision 1.40 2004/01/16 21:20:00 warmerda * Added EMPTY support * * Revision 1.39 2003/08/27 15:40:37 warmerda * added support for generating DB2 V7.2 compatible WKB * * 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.62 2006/11/18 20:04:08 mloskot 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() const{ if( getCoordinateDimension() == 3 ) return wkbLineString25D; else return wkbLineString;}/************************************************************************//* flattenTo2D() *//************************************************************************/void OGRLineString::flattenTo2D(){ Make2D();}/************************************************************************//* getGeometryName() *//************************************************************************/const char * OGRLineString::getGeometryName() const{ return "LINESTRING";}/************************************************************************//* clone() *//************************************************************************/OGRGeometry *OGRLineString::clone() const{ OGRLineString *poNewLineString; poNewLineString = new OGRLineString(); poNewLineString->assignSpatialReference( getSpatialReference() ); poNewLineString->setPoints( nPointCount, paoPoints, padfZ ); poNewLineString->setCoordinateDimension( getCoordinateDimension() ); return poNewLineString;}/************************************************************************//* empty() *//************************************************************************/void OGRLineString::empty(){ setNumPoints( 0 );}/************************************************************************//* getDimension() *//************************************************************************/int OGRLineString::getDimension() const{ return 1;}/************************************************************************//* setCoordinateDimension() *//************************************************************************/void OGRLineString::setCoordinateDimension( int nNewDimension ){ nCoordDimension = nNewDimension; if( nNewDimension == 2 ) Make2D(); else if( nNewDimension == 3 ) Make3D();}/************************************************************************//* WkbSize() *//* *//* Return the size of this object in well known binary *//* representation including the byte order, and type information. *//************************************************************************/int OGRLineString::WkbSize() const{ return 5 + 4 + 8 * nPointCount * getCoordinateDimension();}/************************************************************************//* Make2D() *//************************************************************************/void OGRLineString::Make2D()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -