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

📄 ntf_estlayers.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * $Id: ntf_estlayers.cpp,v 1.19 2003/12/15 16:07:41 warmerda Exp $ * * Project:  NTF Translator * Purpose:  NTFFileReader methods related to establishing the schemas *           of features that could occur in this product and the functions *           for actually performing the NTFRecord to OGRFeature conversion. * 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: ntf_estlayers.cpp,v $ * Revision 1.19  2003/12/15 16:07:41  warmerda * Added CHG_TYPE for landline plus product * * Revision 1.18  2003/01/10 22:27:35  warmerda * Corrected width of CENSUS_CODE ... should be 7 according to * GREATER_LONDON_AUTHORITY.NTF. * * Revision 1.17  2003/01/07 16:46:28  warmerda * Added support for forming polygons by caching line geometries * * Revision 1.16  2002/11/17 05:16:49  warmerda * added meridian 2 support * * Revision 1.15  2002/02/06 15:19:36  warmerda * TEXT_CODE is 4 long, not 3 * * Revision 1.14  2001/08/23 14:47:31  warmerda * Added support for adding an _LIST attribute to the OGRFeatures in * cases of GENERIC features for which an attribute appears more than * once per features.  This has occured with the SAMPE1250.NTF Irish * dataset which has multiple feature codes for some line features. * * Revision 1.13  2001/07/18 04:55:16  warmerda * added CPL_CSVID * * Revision 1.12  2001/01/19 20:31:12  warmerda * expand tabs * * Revision 1.11  2001/01/17 19:08:37  warmerda * added CODELIST support * * Revision 1.10  2000/12/23 05:10:35  warmerda * Segregate referenced collections in BL2000 collections into the COLL_ID_REFS field. * Improve error handling if MAX_LINKS exceeded.  Raise MAX_LINKS to 5000. * * Revision 1.9  2000/12/06 19:31:16  warmerda * added BL2000 support * * Revision 1.8  1999/10/03 03:01:21  warmerda * Up width of real fields derived from "Rn,m" formats by one to account for * the implicit decimal in NTF that is explicit in the length in OGR. * * Revision 1.7  1999/10/01 14:47:51  warmerda * major upgrade: generic, string feature codes, etc * * Revision 1.6  1999/09/14 01:34:36  warmerda * added scale support, and generation of TEXT_HT_GROUND * * Revision 1.5  1999/09/13 14:36:45  warmerda * Mark PROFILE_POINT and PROFILE_LINE as 3D features. * * Revision 1.4  1999/09/13 14:09:10  warmerda * added oscar comment, profile and landline chg_date * * Revision 1.3  1999/09/12 17:18:52  warmerda * Reorganized attributes for address point layers.  Fixed landline point * orient precision. * * Revision 1.2  1999/08/30 16:48:25  warmerda * Added several product types * * Revision 1.1  1999/08/28 03:13:35  warmerda * New */#include <stdarg.h>#include "ntf.h"#include "cpl_string.h"CPL_CVSID("$Id: ntf_estlayers.cpp,v 1.19 2003/12/15 16:07:41 warmerda Exp $");#define MAX_LINK        5000/************************************************************************//*                         TranslateCodePoint()                         *//*                                                                      *//*      Used for code point, and code point plus.                       *//************************************************************************/static OGRFeature *TranslateCodePoint( NTFFileReader *poReader,                                       OGRNTFLayer *poLayer,                                       NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_POINTREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // POINT_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1]));    // Attributes    if( EQUAL(poLayer->GetLayerDefn()->GetName(),"CODE_POINT") )        poReader->ApplyAttributeValues( poFeature, papoGroup,                                        "PC", 1, "PQ", 2, "PR", 3, "TP", 4,                                        "DQ", 5, "RP", 6, "BP", 7, "PD", 8,                                        "MP", 9, "UM", 10, "RV", 11,                                         NULL );    else        poReader->ApplyAttributeValues( poFeature, papoGroup,                                        "PC", 1, "PQ", 2, "PR", 3, "TP", 4,                                        "DQ", 5, "RP", 6, "BP", 7, "PD", 8,                                        "MP", 9, "UM", 10, "RV", 11,                                        "RH", 12, "LH", 13, "CC", 14,                                        "DC", 15, "WC", 16,                                         NULL );    return poFeature;}/************************************************************************//*                       TranslateAddressPoint()                        *//************************************************************************/static OGRFeature *TranslateAddressPoint( NTFFileReader *poReader,                                          OGRNTFLayer *poLayer,                                          NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_POINTREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // POINT_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // CHG_TYPE    poFeature->SetField( 17, papoGroup[0]->GetField( 22, 22 ) );    // CHG_DATE    poFeature->SetField( 18, papoGroup[0]->GetField( 23, 28 ) );    // Geometry    poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1]));    // Attributes    poReader->ApplyAttributeValues( poFeature, papoGroup,                                    "OA", 1, "ON", 2, "DP", 3, "PB", 4,                                    "SB", 5, "BD", 6, "BN", 7, "DR", 8,                                    "TN", 9, "DD", 10, "DL", 11, "PT", 12,                                    "CN", 13, "PC", 14, "SF", 15, "RV", 16,                                    NULL );    return poFeature;}/************************************************************************//*                        TranslateOscarPoint()                         *//*                                                                      *//*      Used for OSCAR Traffic and Asset datasets.                      *//************************************************************************/static OGRFeature *TranslateOscarPoint( NTFFileReader *poReader,                                        OGRNTFLayer *poLayer,                                        NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_POINTREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // POINT_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    int         nGeomId;        poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1],                                                             &nGeomId));    poFeature->SetField( 1, nGeomId );    // Attributes    poReader->ApplyAttributeValues( poFeature, papoGroup,                                    "FC", 2, "OD", 3, "JN", 4, "SN", 5,                                    NULL );    return poFeature;}/************************************************************************//*                         TranslateOscarLine()                         *//************************************************************************/static OGRFeature *TranslateOscarLine( NTFFileReader *poReader,                                       OGRNTFLayer *poLayer,                                       NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_LINEREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // LINE_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    int         nGeomId;        poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1],                                                             &nGeomId));    poFeature->SetField( 1, nGeomId );    // Attributes    poReader->ApplyAttributeValues( poFeature, papoGroup,                                    "FC", 2, "OD", 3, "PN", 4, "LL", 5,                                    "SC", 6, "FW", 7, "RN", 8, "TR", 9,                                    NULL );    return poFeature;}/************************************************************************//*                      TranslateOscarRoutePoint()                      *//************************************************************************/static OGRFeature *TranslateOscarRoutePoint( NTFFileReader *poReader,                                             OGRNTFLayer *poLayer,                                             NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_POINTREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // POINT_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    int         nGeomId;        poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1],                                                             &nGeomId));    poFeature->SetField( 1, nGeomId );    // Attributes    poReader->ApplyAttributeValues( poFeature, papoGroup,                                    "FC", 2, "OD", 3, "JN", 4, "SN", 5,                                    "NP", 6, "RT", 8,                                    NULL );    // PARENT_OSODR    char        **papszTypes, **papszValues;    if( poReader->ProcessAttRecGroup( papoGroup, &papszTypes, &papszValues ) )    {        char    **papszOSODRList = NULL;        for( int i = 0; papszTypes != NULL && papszTypes[i] != NULL; i++ )        {            if( EQUAL(papszTypes[i],"PO") )                papszOSODRList = CSLAddString(papszOSODRList,papszValues[i]);        }        poFeature->SetField( 7, papszOSODRList );        CPLAssert( CSLCount(papszOSODRList) ==                   poFeature->GetFieldAsInteger( 6 ) );        CSLDestroy( papszOSODRList );        CSLDestroy( papszTypes );        CSLDestroy( papszValues );    }    return poFeature;}/************************************************************************//*                      TranslateOscarRouteLine()                       *//************************************************************************/static OGRFeature *TranslateOscarRouteLine( NTFFileReader *poReader,                                            OGRNTFLayer *poLayer,                                            NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_LINEREC        || papoGroup[1]->GetType() != NRT_GEOMETRY )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // LINE_ID    poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    int         nGeomId;        poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1],                                                             &nGeomId));    poFeature->SetField( 1, nGeomId );    // Attributes    poReader->ApplyAttributeValues( poFeature, papoGroup,                                    "FC", 2, "OD", 3, "PN", 4, "LL", 5,                                    "RN", 6, "TR", 7, "NP", 8,                                     NULL );    // PARENT_OSODR    char        **papszTypes, **papszValues;    if( poReader->ProcessAttRecGroup( papoGroup, &papszTypes, &papszValues ) )    {        char    **papszOSODRList = NULL;        for( int i = 0; papszTypes != NULL && papszTypes[i] != NULL; i++ )        {            if( EQUAL(papszTypes[i],"PO") )                papszOSODRList = CSLAddString(papszOSODRList,papszValues[i]);        }        poFeature->SetField( 9, papszOSODRList );        CPLAssert( CSLCount(papszOSODRList) ==                   poFeature->GetFieldAsInteger( 8 ) );

⌨️ 快捷键说明

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