📄 ogrociwritablelayer.cpp
字号:
/****************************************************************************** * $Id: ogrociwritablelayer.cpp,v 1.4 2003/09/17 16:36:34 warmerda Exp $ * * Project: Oracle Spatial Driver * Purpose: Implementation of the OGROCIWritableLayer class. This provides * some services for converting OGRGeometries into Oracle structures * that is shared between OGROCITableLayer and OGROCILoaderLayer. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com> * * 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: ogrociwritablelayer.cpp,v $ * Revision 1.4 2003/09/17 16:36:34 warmerda * fixed setting of dimension for point objects * * Revision 1.3 2003/08/05 01:59:09 warmerda * Default unsized string fields to 2047 instead of 4000 to avoid problem reading * fields of width 2048 or more as reported by Ned. * * Revision 1.2 2003/05/21 03:54:01 warmerda * expand tabs * * Revision 1.1 2003/04/04 06:17:47 warmerda * New * */#include "ogr_oci.h"#include "cpl_conv.h"#include "cpl_string.h"CPL_CVSID("$Id: ogrociwritablelayer.cpp,v 1.4 2003/09/17 16:36:34 warmerda Exp $");/************************************************************************//* OGROCIWritableLayer() *//************************************************************************/OGROCIWritableLayer::OGROCIWritableLayer(){ nDimension = 3; nSRID = -1; nOrdinalCount = 0; nOrdinalMax = 0; padfOrdinals = NULL; nElemInfoCount = 0; nElemInfoMax = 0; panElemInfo = NULL; bLaunderColumnNames = TRUE; bTruncationReported = FALSE; nSRID = -1; poSRS = NULL; papszOptions = NULL;}/************************************************************************//* ~OGROCIWritableLayer() *//************************************************************************/OGROCIWritableLayer::~OGROCIWritableLayer(){ CPLFree( padfOrdinals ); CPLFree( panElemInfo ); CSLDestroy( papszOptions );}/************************************************************************//* PushOrdinal() *//************************************************************************/void OGROCIWritableLayer::PushOrdinal( double dfOrd ){ if( nOrdinalCount == nOrdinalMax ) { nOrdinalMax = nOrdinalMax * 2 + 100; padfOrdinals = (double *) CPLRealloc(padfOrdinals, sizeof(double) * nOrdinalMax); } padfOrdinals[nOrdinalCount++] = dfOrd;}/************************************************************************//* PushElemInfo() *//************************************************************************/void OGROCIWritableLayer::PushElemInfo( int nOffset, int nEType, int nInterp ){ if( nElemInfoCount+3 >= nElemInfoMax ) { nElemInfoMax = nElemInfoMax * 2 + 100; panElemInfo = (int *) CPLRealloc(panElemInfo,sizeof(int)*nElemInfoMax); } panElemInfo[nElemInfoCount++] = nOffset; panElemInfo[nElemInfoCount++] = nEType; panElemInfo[nElemInfoCount++] = nInterp;}/************************************************************************//* TranslateElementGroup() *//* *//* Append one or more element groups to the existing element *//* info and ordinates lists for the passed geometry. *//************************************************************************/OGRErr OGROCIWritableLayer::TranslateElementGroup( OGRGeometry *poGeometry ){ switch( wkbFlatten(poGeometry->getGeometryType()) ) { case wkbPoint: { OGRPoint *poPoint = (OGRPoint *) poGeometry; PushElemInfo( nOrdinalCount+1, 1, 1 ); PushOrdinal( poPoint->getX() ); PushOrdinal( poPoint->getY() ); if( nDimension == 3 ) PushOrdinal( poPoint->getZ() ); return OGRERR_NONE; } case wkbLineString: { OGRLineString *poLine = (OGRLineString *) poGeometry; int iVert; PushElemInfo( nOrdinalCount+1, 2, 1 ); for( iVert = 0; iVert < poLine->getNumPoints(); iVert++ ) { PushOrdinal( poLine->getX(iVert) ); PushOrdinal( poLine->getY(iVert) ); if( nDimension == 3 ) PushOrdinal( poLine->getZ(iVert) ); } return OGRERR_NONE; } case wkbPolygon: { OGRPolygon *poPoly = (OGRPolygon *) poGeometry; int iRing; for( iRing = -1; iRing < poPoly->getNumInteriorRings(); iRing++ ) { OGRLinearRing *poRing; int iVert; if( iRing == -1 ) poRing = poPoly->getExteriorRing(); else poRing = poPoly->getInteriorRing(iRing); if( iRing == -1 ) PushElemInfo( nOrdinalCount+1, 1003, 1 ); else PushElemInfo( nOrdinalCount+1, 2003, 1 ); if( (iRing == -1 && poRing->isClockwise()) || (iRing != -1 && !poRing->isClockwise()) ) { for( iVert = poRing->getNumPoints()-1; iVert >= 0; iVert-- ) { PushOrdinal( poRing->getX(iVert) ); PushOrdinal( poRing->getY(iVert) ); if( nDimension == 3 ) PushOrdinal( poRing->getZ(iVert) ); } } else { for( iVert = 0; iVert < poRing->getNumPoints(); iVert++ ) { PushOrdinal( poRing->getX(iVert) ); PushOrdinal( poRing->getY(iVert) ); if( nDimension == 3 ) PushOrdinal( poRing->getZ(iVert) ); } } } return OGRERR_NONE; } default: { return OGRERR_FAILURE; } }}/************************************************************************//* ReportTruncation() *//************************************************************************/void OGROCIWritableLayer::ReportTruncation( OGRFieldDefn * psFldDefn ){ if( bTruncationReported ) return; CPLError( CE_Warning, CPLE_AppDefined, "The value for the field %s is being truncated to fit the\n" "declared width/precision of the field. No more truncations\n" "for table %s will be reported.", psFldDefn->GetNameRef(), poFeatureDefn->GetName() ); bTruncationReported = TRUE;}/************************************************************************//* SetOptions() *//* *//* Set layer creation or other options. *//************************************************************************/void OGROCIWritableLayer::SetOptions( char **papszOptionsIn ){ CSLDestroy( papszOptions ); papszOptions = CSLDuplicate( papszOptionsIn );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -