📄 ogrlinearring.cpp
字号:
/****************************************************************************** * $Id: ogrlinearring.cpp,v 1.27 2006/11/18 20:03:53 mloskot Exp $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: The OGRLinearRing 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: ogrlinearring.cpp,v $ * Revision 1.27 2006/11/18 20:03:53 mloskot * Changed type of buffer size testers from size_t to int. * * Revision 1.26 2006/10/03 09:23:55 dron * Removed too verbosive debug output. * * Revision 1.25 2006/09/20 13:10:32 osemykin * Really fixed nBytesAvailable tests inside importFromWkb() * * Revision 1.24 2006/09/05 12:14:28 mloskot * Fixed nBytesAvailable tests inside importFromWkb() * in OGRLineString and OGRLinearRing classes. * * Revision 1.23 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.22 2006/07/14 20:30:25 mloskot * Fixed new issue related to Bug 1195. Fixed Bug 313. * * Revision 1.21 2006/07/12 11:53:27 mloskot * Fixed Bug 1195 and Bug 1230. * * Revision 1.20 2006/06/19 23:19:45 mloskot * Added new functions OGRLinearRing::isPointInRing and OGRPolygon::IsPointOnSurface. * * Revision 1.19 2006/03/31 17:44:20 fwarmerdam * header updates * * Revision 1.18 2004/09/17 15:05:36 fwarmerdam * added get_Area() support * * Revision 1.17 2004/07/10 04:51:42 warmerda * added closeRings * * Revision 1.16 2004/02/21 15:36:14 warmerda * const correctness updates for geometry: bug 289 * * Revision 1.15 2003/09/11 22:47:54 aamici * add class constructors and destructors where needed in order to * let the mingw/cygwin binutils produce sensible partially linked objet files * with 'ld -r'. * * Revision 1.14 2003/07/08 13:59:35 warmerda * added poSrcRing check in copy constructor, bug 361 * * Revision 1.13 2003/05/28 19:16:42 warmerda * fixed up argument names and stuff for docs * * Revision 1.12 2003/01/14 22:13:35 warmerda * added isClockwise() method on OGRLinearRing * * Revision 1.11 2002/10/24 20:38:45 warmerda * fixed bug byte swapping point count in exporttowkb * * Revision 1.10 2002/05/02 19:44:53 warmerda * fixed 3D binary support for polygon/linearring * * Revision 1.9 2002/04/17 21:46:22 warmerda * Ensure padfZ copied in copy constructor. * * Revision 1.8 2002/02/22 22:24:31 warmerda * fixed 3d support in clone * * Revision 1.7 2001/07/18 05:03:05 warmerda * added CPL_CVSID * * Revision 1.6 1999/11/18 19:02:19 warmerda * expanded tabs * * Revision 1.5 1999/07/08 20:25:39 warmerda * Remove getGeometryType() method ... now returns wkbLineString. * * Revision 1.4 1999/06/25 20:44:43 warmerda * implemented assignSpatialReference, carry properly * * Revision 1.3 1999/05/23 05:34:40 warmerda * added support for clone(), multipolygons and geometry collections * * Revision 1.2 1999/05/20 14:35:44 warmerda * added support for well known text format * * Revision 1.1 1999/03/30 21:21:05 warmerda * New * */#include "ogr_geometry.h"#include "ogr_p.h"CPL_CVSID("$Id: ogrlinearring.cpp,v 1.27 2006/11/18 20:03:53 mloskot Exp $");/************************************************************************//* OGRLinearRing() *//************************************************************************/OGRLinearRing::OGRLinearRing(){}/************************************************************************//* ~OGRLinearRing() *//************************************************************************/OGRLinearRing::~OGRLinearRing(){}/************************************************************************//* OGRLinearRing() *//************************************************************************/OGRLinearRing::OGRLinearRing( OGRLinearRing * poSrcRing ){ if( poSrcRing == NULL ) { CPLDebug( "OGR", "OGRLinearRing::OGRLinearRing(OGRLinearRing*poSrcRing) - passed in ring is NULL!" ); return; } setNumPoints( poSrcRing->getNumPoints() ); memcpy( paoPoints, poSrcRing->paoPoints, sizeof(OGRRawPoint) * getNumPoints() ); if( poSrcRing->padfZ ) { Make3D(); memcpy( padfZ, poSrcRing->padfZ, sizeof(double) * getNumPoints() ); }}/************************************************************************//* getGeometryName() *//************************************************************************/const char * OGRLinearRing::getGeometryName() const { return "LINEARRING";}/************************************************************************//* WkbSize() *//* *//* Disable this method. *//************************************************************************/int OGRLinearRing::WkbSize() const{ return 0;}/************************************************************************//* importFromWkb() *//* *//* Disable method for this class. *//************************************************************************/OGRErr OGRLinearRing::importFromWkb( unsigned char *pabyData, int nSize ) { (void) pabyData; (void) nSize; return OGRERR_UNSUPPORTED_OPERATION;}/************************************************************************//* exportToWkb() *//* *//* Disable method for this class. *//************************************************************************/OGRErr OGRLinearRing::exportToWkb( OGRwkbByteOrder eByteOrder, unsigned char * pabyData ) const{ (void) eByteOrder; (void) pabyData; return OGRERR_UNSUPPORTED_OPERATION;}/************************************************************************//* _importFromWkb() *//* *//* Helper method for OGRPolygon. NOT A NORMAL importFromWkb() *//* method! *//************************************************************************/OGRErr OGRLinearRing::_importFromWkb( OGRwkbByteOrder eByteOrder, int b3D, unsigned char * pabyData, int nBytesAvailable ) { if( nBytesAvailable < 4 && nBytesAvailable != -1 ) return OGRERR_NOT_ENOUGH_DATA;/* -------------------------------------------------------------------- *//* Get the vertex count. *//* -------------------------------------------------------------------- */ int nNewNumPoints; memcpy( &nNewNumPoints, pabyData, 4 ); if( OGR_SWAP( eByteOrder ) ) nNewNumPoints = CPL_SWAP32(nNewNumPoints); /* Check if the wkb stream buffer is big enough to store * fetched number of points. * 16 or 24 - size of point structure */ int nPointSize = (b3D ? 24 : 16); int nBufferMinSize = nPointSize * nNewNumPoints; if( nBufferMinSize > nBytesAvailable && nBytesAvailable > 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "Length of input WKB is too small" ); return OGRERR_NOT_ENOUGH_DATA; } /* (Re)Allocation of paoPoints buffer. */ setNumPoints( nNewNumPoints ); if( b3D ) Make3D(); else Make2D(); /* -------------------------------------------------------------------- *//* Get the vertices *//* -------------------------------------------------------------------- */ int i = 0; int nBytesToCopy = 0; if( !b3D ) { nBytesToCopy = 16 * nPointCount; if( nBytesToCopy > nBytesAvailable && nBytesAvailable > 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "WKB buffer with OGRLinearRing points is too small! \ \n\tWKB stream may be corrupted or it is EWKB stream which is not supported"); return OGRERR_NOT_ENOUGH_DATA; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -