#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project:  GDAL/OGR Test Suite
# Purpose:  Test GPX driver functionality.
# Author:   Even Rouault <even dot rouault at mines dash paris dot org>
# 
###############################################################################
# Copyright (c) 2007, Even Rouault <even dot rouault at mines dash paris dot org>
#
# 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.
###############################################################################

import os
import sys
import string

sys.path.append( '../pymod' )

import gdaltest
import ogrtest
import ogr
import osr
import gdal

def ogr_gpx_init():
    gdaltest.gpx_ds = None

    try:
        gdaltest.gpx_ds = ogr.Open( 'data/test.gpx' )
    except:
        gdaltest.gpx_ds = None

    if gdaltest.gpx_ds is None:
        gdaltest.have_gpx = 0
    else:
        gdaltest.have_gpx = 1

    if not gdaltest.have_gpx:
        return 'skip'

    if gdaltest.gpx_ds.GetLayerCount() != 5:
        gdaltest.post_reason( 'wrong number of layers' )
        return 'fail'

    return 'success'

###############################################################################
# Test waypoints gpx layer.

def ogr_gpx_1():
    if not gdaltest.have_gpx:
        return 'skip'
    
    if gdaltest.gpx_ds is None:
        return 'fail'

    lyr = gdaltest.gpx_ds.GetLayerByName( 'waypoints' )
    
    expect = [2, None]

    tr = ogrtest.check_features_against_list( lyr, 'ele', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['waypoint name', None]

    tr = ogrtest.check_features_against_list( lyr, 'name', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['href', None]

    tr = ogrtest.check_features_against_list( lyr, 'link1_href', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['text', None]

    tr = ogrtest.check_features_against_list( lyr, 'link1_text', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['type', None]

    tr = ogrtest.check_features_against_list( lyr, 'link1_type', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['href2', None]

    tr = ogrtest.check_features_against_list( lyr, 'link2_href', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['text2', None]

    tr = ogrtest.check_features_against_list( lyr, 'link2_text', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['type2', None]

    tr = ogrtest.check_features_against_list( lyr, 'link2_type', expect )
    if not tr:
        return 'fail'
    
    lyr.ResetReading()
    
    expect = ['2007/11/25 17:58:00+01', None]

    tr = ogrtest.check_features_against_list( lyr, 'time', expect )
    if not tr:
        return 'fail'

    lyr.ResetReading()
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'POINT (1 0)',
                                       max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'POINT (4 3)',
                                       max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    return 'success'

###############################################################################
# Test routes gpx layer.

def ogr_gpx_2():
    if not gdaltest.have_gpx:
        return 'skip'
    
    if gdaltest.gpx_ds is None:
        return 'fail'

    lyr = gdaltest.gpx_ds.GetLayerByName( 'routes' )

    lyr.ResetReading()
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'LINESTRING (6 5,9 8,12 11)', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'LINESTRING EMPTY', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    return 'success'


###############################################################################
# Test route_points gpx layer.

def ogr_gpx_3():
    if not gdaltest.have_gpx:
        return 'skip'
    
    if gdaltest.gpx_ds is None:
        return 'fail'

    lyr = gdaltest.gpx_ds.GetLayerByName( 'route_points' )

    expect = ['route point name', None, None]

    tr = ogrtest.check_features_against_list( lyr, 'name', expect )
    
    lyr.ResetReading()
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'POINT (6 5)', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    return 'success'

###############################################################################
# Test tracks gpx layer.

def ogr_gpx_4():
    if not gdaltest.have_gpx:
        return 'skip'

    if gdaltest.gpx_ds is None:
        return 'fail'

    lyr = gdaltest.gpx_ds.GetLayerByName( 'tracks' )

    lyr.ResetReading()
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'MULTILINESTRING ((15 14,18 17),(21 20,24 23))', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'MULTILINESTRING EMPTY', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    feat = lyr.GetNextFeature()
    f_geom = feat.GetGeometryRef()
    if f_geom.ExportToWkt()!= 'MULTILINESTRING EMPTY':
        return 'fail'
    feat.Destroy()
    
    return 'success'

###############################################################################
# Test route_points gpx layer.

def ogr_gpx_5():
    if not gdaltest.have_gpx:
        return 'skip'
    
    if gdaltest.gpx_ds is None:
        return 'fail'

    lyr = gdaltest.gpx_ds.GetLayerByName( 'track_points' )

    expect = ['track point name', None, None, None]

    tr = ogrtest.check_features_against_list( lyr, 'name', expect )
    
    lyr.ResetReading()
    feat = lyr.GetNextFeature()
    if ogrtest.check_feature_geometry( feat, 'POINT (15 14)', max_error = 0.0001 ) != 0:
        return 'fail'
    feat.Destroy()
    
    return 'success'

###############################################################################
# Copy our small gpx file to a new gpx file. 

def ogr_gpx_6():
    if not gdaltest.have_gpx:
        return 'skip'
    
    if gdaltest.gpx_ds is None:
        return 'skip'
    
    try:
        gdal.PushErrorHandler( 'CPLQuietErrorHandler' )
        ogr.GetDriverByName('CSV').DeleteDataSource( 'tmp/gpx.gpx' )
        gdal.PopErrorHandler()
    except:
        pass

    co_opts = [ ]
    
    # Duplicate waypoints
    gpx_lyr = gdaltest.gpx_ds.GetLayerByName( 'waypoints' )

    gpx2_ds = ogr.GetDriverByName('GPX').CreateDataSource('tmp/gpx.gpx',
                                                          options = co_opts )

    gpx2_lyr = gpx2_ds.CreateLayer( 'waypoints', geom_type = ogr.wkbPoint )

    gpx_lyr.ResetReading()

    dst_feat = ogr.Feature( feature_def = gpx2_lyr.GetLayerDefn() )
    
    feat = gpx_lyr.GetNextFeature()
    while feat is not None:
        dst_feat.SetFrom( feat )
        if gpx2_lyr.CreateFeature( dst_feat ) != 0:
            gdaltest.post_reason('CreateFeature failed.')
            return 'fail'

        feat = gpx_lyr.GetNextFeature()

    dst_feat.Destroy()

    # Duplicate routes
    gpx_lyr = gdaltest.gpx_ds.GetLayerByName( 'routes' )

    gpx2_lyr = gpx2_ds.CreateLayer( 'routes', geom_type = ogr.wkbLineString )

    gpx_lyr.ResetReading()

    dst_feat = ogr.Feature( feature_def = gpx2_lyr.GetLayerDefn() )
    
    feat = gpx_lyr.GetNextFeature()
    while feat is not None:
        dst_feat.SetFrom( feat )
        if gpx2_lyr.CreateFeature( dst_feat ) != 0:
            gdaltest.post_reason('CreateFeature failed.')
            return 'fail'

        feat = gpx_lyr.GetNextFeature()

    dst_feat.Destroy()
    
    # Duplicate tracks
    gpx_lyr = gdaltest.gpx_ds.GetLayerByName( 'tracks' )

    gpx2_lyr = gpx2_ds.CreateLayer( 'tracks', geom_type = ogr.wkbMultiLineString )

    gpx_lyr.ResetReading()

    dst_feat = ogr.Feature( feature_def = gpx2_lyr.GetLayerDefn() )
    
    feat = gpx_lyr.GetNextFeature()
    while feat is not None:
        dst_feat.SetFrom( feat )
        if gpx2_lyr.CreateFeature( dst_feat ) != 0:
            gdaltest.post_reason('CreateFeature failed.')
            return 'fail'

        feat = gpx_lyr.GetNextFeature()

    dst_feat.Destroy()
    
    gpx_lyr = None
    gpx2_lyr = None

    # Explicit destroy is required for old-gen python bindings
    gpx2_ds.Destroy()
    gdaltest.gpx_ds.Destroy()

    gdaltest.gpx_ds = ogr.Open( 'tmp/gpx.gpx' )

    return 'success'

###############################################################################
# Output extra fields as <extensions>. 

def ogr_gpx_7():
    if not gdaltest.have_gpx:
        return 'skip'

    if gdaltest.gpx_ds is not None:
        gdaltest.gpx_ds.Destroy()
    gdaltest.gpx_ds = None
    
    bna_ds = ogr.Open( 'data/bna_for_gpx.bna' )
    
    try:
        os.remove ('tmp/gpx.gpx')
    except:
        pass

    co_opts = [ 'GPX_USE_EXTENSIONS=yes' ]

    # Duplicate waypoints
    bna_lyr = bna_ds.GetLayerByName( 'bna_for_gpx_points' )

    gdaltest.gpx_ds = ogr.GetDriverByName('GPX').CreateDataSource('tmp/gpx.gpx',
                                                          options = co_opts )

    gpx_lyr = gdaltest.gpx_ds.CreateLayer( 'waypoints', geom_type = ogr.wkbPoint )

    bna_lyr.ResetReading()

    for i in range(bna_lyr.GetLayerDefn().GetFieldCount()):
        field_defn = bna_lyr.GetLayerDefn().GetFieldDefn(i)
        gpx_lyr.CreateField( field_defn )

    dst_feat = ogr.Feature( feature_def = gpx_lyr.GetLayerDefn() )

    feat = bna_lyr.GetNextFeature()
    while feat is not None:
        dst_feat.SetFrom( feat )
        if gpx_lyr.CreateFeature( dst_feat ) != 0:
            gdaltest.post_reason('CreateFeature failed.')
            return 'fail'

        feat = bna_lyr.GetNextFeature()

    dst_feat.Destroy()

    bna_ds.Destroy()
    gdaltest.gpx_ds.Destroy()
    gdaltest.gpx_ds = None
    
#Now check that the extensions fields have been well written
    gdaltest.gpx_ds = ogr.Open('tmp/gpx.gpx')
    gpx_lyr = gdaltest.gpx_ds.GetLayerByName( 'waypoints' )
    
    expect = ['PID1', 'PID2']

    tr = ogrtest.check_features_against_list( gpx_lyr, 'ogr_Primary_ID', expect )
    if not tr:
        return 'fail'
    
    gpx_lyr.ResetReading()
    
    expect = ['SID1', 'SID2']

    tr = ogrtest.check_features_against_list( gpx_lyr, 'ogr_Secondary_ID', expect )
    if not tr:
        return 'fail'
    
    gpx_lyr.ResetReading()
    
    expect = ['TID1', None]

    tr = ogrtest.check_features_against_list( gpx_lyr, 'ogr_Third_ID', expect )
    if not tr:
        return 'fail'

    return 'success'

###############################################################################
# Output extra fields as <extensions>. 

def ogr_gpx_8():
    if not gdaltest.have_gpx:
        return 'skip'

    if gdaltest.gpx_ds is not None:
        gdaltest.gpx_ds.Destroy()
    gdaltest.gpx_ds = None

    try:
        os.remove ('tmp/gpx.gpx')
    except:
        pass

    gdaltest.gpx_ds = ogr.GetDriverByName('GPX').CreateDataSource('tmp/gpx.gpx', options = ['LINEFORMAT=LF'])

    lyr = gdaltest.gpx_ds.CreateLayer( 'route_points', geom_type = ogr.wkbPoint )

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(2 49)')
    feat.SetField('route_name', 'ROUTE_NAME')
    feat.SetField('route_fid', 0)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 50)')
    feat.SetField('route_name', '--ignored--')
    feat.SetField('route_fid', 0)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 51)')
    feat.SetField('route_name', 'ROUTE_NAME2')
    feat.SetField('route_fid', 1)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 49)')
    feat.SetField('route_fid', 1)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    lyr = gdaltest.gpx_ds.CreateLayer( 'track_points', geom_type = ogr.wkbPoint )

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(2 49)')
    feat.SetField('track_name', 'TRACK_NAME')
    feat.SetField('track_fid', 0)
    feat.SetField('track_seg_id', 0)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 50)')
    feat.SetField('track_name', '--ignored--')
    feat.SetField('track_fid', 0)
    feat.SetField('track_seg_id', 0)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 51)')
    feat.SetField('track_fid', 0)
    feat.SetField('track_seg_id', 1)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    feat = ogr.Feature(lyr.GetLayerDefn())
    geom = ogr.CreateGeometryFromWkt('POINT(3 49)')
    feat.SetField('track_name', 'TRACK_NAME2')
    feat.SetField('track_fid', 1)
    feat.SetField('track_seg_id', 0)
    feat.SetGeometry(geom)
    lyr.CreateFeature(feat)

    gdaltest.gpx_ds.Destroy()
    gdaltest.gpx_ds = None

    f = open('tmp/gpx.gpx','rb')
    f_ref = open('data/ogr_gpx_8_ref.txt','rb')
    f_content = f.read()
    f_ref_content = f_ref.read()
    f.close()
    f_ref.close()

    if f_content.find(f_ref_content) == -1:
        gdaltest.post_reason('did not get expected result')
        print(f_content)
        return 'fail'

    return 'success'

###############################################################################
# 

def ogr_gpx_cleanup():

    if gdaltest.gpx_ds is not None:
        gdaltest.gpx_ds.Destroy()
    gdaltest.gpx_ds = None
    try:
        os.remove ('tmp/gpx.gpx')
    except:
        pass
    return 'success'

gdaltest_list = [ 
    ogr_gpx_init,
    ogr_gpx_1,
    ogr_gpx_2,
    ogr_gpx_3,
    ogr_gpx_4,
    ogr_gpx_5,
    ogr_gpx_6,
# Rerun test 1, 2 and 4 with generated tmp/tmp.gpx
    ogr_gpx_1,
    ogr_gpx_2,
    ogr_gpx_4,
    ogr_gpx_7,
    ogr_gpx_8,
    ogr_gpx_cleanup ]

if __name__ == '__main__':

    gdaltest.setup_run( 'ogr_gpx' )

    gdaltest.run_tests( gdaltest_list )

    gdaltest.summarize()


[((1597, 1624), 'sys.path.append', 'sys.path.append', (['"""../pymod"""'], {}), "('../pymod')\n", (1612, 1624), False, 'import sys\n'), ((2400, 2443), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""waypoints"""'], {}), "('waypoints')\n", (2430, 2443), False, 'import gdaltest\n'), ((2484, 2539), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""ele"""', 'expect'], {}), "(lyr, 'ele', expect)\n", (2519, 2539), False, 'import ogrtest\n'), ((2659, 2715), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""name"""', 'expect'], {}), "(lyr, 'name', expect)\n", (2694, 2715), False, 'import ogrtest\n'), ((2826, 2888), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link1_href"""', 'expect'], {}), "(lyr, 'link1_href', expect)\n", (2861, 2888), False, 'import ogrtest\n'), ((2999, 3061), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link1_text"""', 'expect'], {}), "(lyr, 'link1_text', expect)\n", (3034, 3061), False, 'import ogrtest\n'), ((3172, 3234), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link1_type"""', 'expect'], {}), "(lyr, 'link1_type', expect)\n", (3207, 3234), False, 'import ogrtest\n'), ((3346, 3408), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link2_href"""', 'expect'], {}), "(lyr, 'link2_href', expect)\n", (3381, 3408), False, 'import ogrtest\n'), ((3520, 3582), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link2_text"""', 'expect'], {}), "(lyr, 'link2_text', expect)\n", (3555, 3582), False, 'import ogrtest\n'), ((3694, 3756), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""link2_type"""', 'expect'], {}), "(lyr, 'link2_type', expect)\n", (3729, 3756), False, 'import ogrtest\n'), ((3885, 3941), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""time"""', 'expect'], {}), "(lyr, 'time', expect)\n", (3920, 3941), False, 'import ogrtest\n'), ((4680, 4720), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""routes"""'], {}), "('routes')\n", (4710, 4720), False, 'import gdaltest\n'), ((5371, 5417), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""route_points"""'], {}), "('route_points')\n", (5401, 5417), False, 'import gdaltest\n'), ((5477, 5533), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""name"""', 'expect'], {}), "(lyr, 'name', expect)\n", (5512, 5533), False, 'import ogrtest\n'), ((5992, 6032), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""tracks"""'], {}), "('tracks')\n", (6022, 6032), False, 'import gdaltest\n'), ((6874, 6920), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""track_points"""'], {}), "('track_points')\n", (6904, 6920), False, 'import gdaltest\n'), ((6986, 7042), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['lyr', '"""name"""', 'expect'], {}), "(lyr, 'name', expect)\n", (7021, 7042), False, 'import ogrtest\n'), ((7776, 7819), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""waypoints"""'], {}), "('waypoints')\n", (7806, 7819), False, 'import gdaltest\n'), ((8489, 8529), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""routes"""'], {}), "('routes')\n", (8519, 8529), False, 'import gdaltest\n'), ((9053, 9093), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""tracks"""'], {}), "('tracks')\n", (9083, 9093), False, 'import gdaltest\n'), ((9714, 9739), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (9737, 9739), False, 'import gdaltest\n'), ((9763, 9786), 'ogr.Open', 'ogr.Open', (['"""tmp/gpx.gpx"""'], {}), "('tmp/gpx.gpx')\n", (9771, 9786), False, 'import ogr\n'), ((10118, 10150), 'ogr.Open', 'ogr.Open', (['"""data/bna_for_gpx.bna"""'], {}), "('data/bna_for_gpx.bna')\n", (10126, 10150), False, 'import ogr\n'), ((10532, 10596), 'gdaltest.gpx_ds.CreateLayer', 'gdaltest.gpx_ds.CreateLayer', (['"""waypoints"""'], {'geom_type': 'ogr.wkbPoint'}), "('waypoints', geom_type=ogr.wkbPoint)\n", (10559, 10596), False, 'import gdaltest\n'), ((11184, 11209), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (11207, 11209), False, 'import gdaltest\n'), ((11325, 11348), 'ogr.Open', 'ogr.Open', (['"""tmp/gpx.gpx"""'], {}), "('tmp/gpx.gpx')\n", (11333, 11348), False, 'import ogr\n'), ((11363, 11406), 'gdaltest.gpx_ds.GetLayerByName', 'gdaltest.gpx_ds.GetLayerByName', (['"""waypoints"""'], {}), "('waypoints')\n", (11393, 11406), False, 'import gdaltest\n'), ((11454, 11524), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['gpx_lyr', '"""ogr_Primary_ID"""', 'expect'], {}), "(gpx_lyr, 'ogr_Primary_ID', expect)\n", (11489, 11524), False, 'import ogrtest\n'), ((11641, 11713), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['gpx_lyr', '"""ogr_Secondary_ID"""', 'expect'], {}), "(gpx_lyr, 'ogr_Secondary_ID', expect)\n", (11676, 11713), False, 'import ogrtest\n'), ((11828, 11896), 'ogrtest.check_features_against_list', 'ogrtest.check_features_against_list', (['gpx_lyr', '"""ogr_Third_ID"""', 'expect'], {}), "(gpx_lyr, 'ogr_Third_ID', expect)\n", (11863, 11896), False, 'import ogrtest\n'), ((12438, 12505), 'gdaltest.gpx_ds.CreateLayer', 'gdaltest.gpx_ds.CreateLayer', (['"""route_points"""'], {'geom_type': 'ogr.wkbPoint'}), "('route_points', geom_type=ogr.wkbPoint)\n", (12465, 12505), False, 'import gdaltest\n'), ((12565, 12605), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(2 49)"""'], {}), "('POINT(2 49)')\n", (12590, 12605), False, 'import ogr\n'), ((12796, 12836), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 50)"""'], {}), "('POINT(3 50)')\n", (12821, 12836), False, 'import ogr\n'), ((13028, 13068), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 51)"""'], {}), "('POINT(3 51)')\n", (13053, 13068), False, 'import ogr\n'), ((13260, 13300), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 49)"""'], {}), "('POINT(3 49)')\n", (13285, 13300), False, 'import ogr\n'), ((13401, 13468), 'gdaltest.gpx_ds.CreateLayer', 'gdaltest.gpx_ds.CreateLayer', (['"""track_points"""'], {'geom_type': 'ogr.wkbPoint'}), "('track_points', geom_type=ogr.wkbPoint)\n", (13428, 13468), False, 'import gdaltest\n'), ((13528, 13568), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(2 49)"""'], {}), "('POINT(2 49)')\n", (13553, 13568), False, 'import ogr\n'), ((13796, 13836), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 50)"""'], {}), "('POINT(3 50)')\n", (13821, 13836), False, 'import ogr\n'), ((14065, 14105), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 51)"""'], {}), "('POINT(3 51)')\n", (14090, 14105), False, 'import ogr\n'), ((14287, 14327), 'ogr.CreateGeometryFromWkt', 'ogr.CreateGeometryFromWkt', (['"""POINT(3 49)"""'], {}), "('POINT(3 49)')\n", (14312, 14327), False, 'import ogr\n'), ((14506, 14531), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (14529, 14531), False, 'import gdaltest\n'), ((15509, 15538), 'gdaltest.setup_run', 'gdaltest.setup_run', (['"""ogr_gpx"""'], {}), "('ogr_gpx')\n", (15527, 15538), False, 'import gdaltest\n'), ((15546, 15579), 'gdaltest.run_tests', 'gdaltest.run_tests', (['gdaltest_list'], {}), '(gdaltest_list)\n', (15564, 15579), False, 'import gdaltest\n'), ((15587, 15607), 'gdaltest.summarize', 'gdaltest.summarize', ([], {}), '()\n', (15605, 15607), False, 'import gdaltest\n'), ((1777, 1802), 'ogr.Open', 'ogr.Open', (['"""data/test.gpx"""'], {}), "('data/test.gpx')\n", (1785, 1802), False, 'import ogr\n'), ((2012, 2043), 'gdaltest.gpx_ds.GetLayerCount', 'gdaltest.gpx_ds.GetLayerCount', ([], {}), '()\n', (2041, 2043), False, 'import gdaltest\n'), ((2058, 2104), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""wrong number of layers"""'], {}), "('wrong number of layers')\n", (2078, 2104), False, 'import gdaltest\n'), ((4044, 4113), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""POINT (1 0)"""'], {'max_error': '(0.0001)'}), "(feat, 'POINT (1 0)', max_error=0.0001)\n", (4074, 4113), False, 'import ogrtest\n'), ((4248, 4317), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""POINT (4 3)"""'], {'max_error': '(0.0001)'}), "(feat, 'POINT (4 3)', max_error=0.0001)\n", (4278, 4317), False, 'import ogrtest\n'), ((4786, 4874), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""LINESTRING (6 5,9 8,12 11)"""'], {'max_error': '(0.0001)'}), "(feat, 'LINESTRING (6 5,9 8,12 11)',\n    max_error=0.0001)\n", (4816, 4874), False, 'import ogrtest\n'), ((4966, 5040), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""LINESTRING EMPTY"""'], {'max_error': '(0.0001)'}), "(feat, 'LINESTRING EMPTY', max_error=0.0001)\n", (4996, 5040), False, 'import ogrtest\n'), ((5603, 5672), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""POINT (6 5)"""'], {'max_error': '(0.0001)'}), "(feat, 'POINT (6 5)', max_error=0.0001)\n", (5633, 5672), False, 'import ogrtest\n'), ((6098, 6205), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""MULTILINESTRING ((15 14,18 17),(21 20,24 23))"""'], {'max_error': '(0.0001)'}), "(feat,\n    'MULTILINESTRING ((15 14,18 17),(21 20,24 23))', max_error=0.0001)\n", (6128, 6205), False, 'import ogrtest\n'), ((6297, 6376), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""MULTILINESTRING EMPTY"""'], {'max_error': '(0.0001)'}), "(feat, 'MULTILINESTRING EMPTY', max_error=0.0001)\n", (6327, 6376), False, 'import ogrtest\n'), ((7112, 7183), 'ogrtest.check_feature_geometry', 'ogrtest.check_feature_geometry', (['feat', '"""POINT (15 14)"""'], {'max_error': '(0.0001)'}), "(feat, 'POINT (15 14)', max_error=0.0001)\n", (7142, 7183), False, 'import ogrtest\n'), ((7539, 7584), 'gdal.PushErrorHandler', 'gdal.PushErrorHandler', (['"""CPLQuietErrorHandler"""'], {}), "('CPLQuietErrorHandler')\n", (7560, 7584), False, 'import gdal\n'), ((7664, 7686), 'gdal.PopErrorHandler', 'gdal.PopErrorHandler', ([], {}), '()\n', (7684, 7686), False, 'import gdal\n'), ((10047, 10072), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (10070, 10072), False, 'import gdaltest\n'), ((10175, 10199), 'os.remove', 'os.remove', (['"""tmp/gpx.gpx"""'], {}), "('tmp/gpx.gpx')\n", (10184, 10199), False, 'import os\n'), ((12194, 12219), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (12217, 12219), False, 'import gdaltest\n'), ((12265, 12289), 'os.remove', 'os.remove', (['"""tmp/gpx.gpx"""'], {}), "('tmp/gpx.gpx')\n", (12274, 12289), False, 'import os\n'), ((14784, 14835), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""did not get expected result"""'], {}), "('did not get expected result')\n", (14804, 14835), False, 'import gdaltest\n'), ((15058, 15083), 'gdaltest.gpx_ds.Destroy', 'gdaltest.gpx_ds.Destroy', ([], {}), '()\n', (15081, 15083), False, 'import gdaltest\n'), ((15128, 15152), 'os.remove', 'os.remove', (['"""tmp/gpx.gpx"""'], {}), "('tmp/gpx.gpx')\n", (15137, 15152), False, 'import os\n'), ((7837, 7863), 'ogr.GetDriverByName', 'ogr.GetDriverByName', (['"""GPX"""'], {}), "('GPX')\n", (7856, 7863), False, 'import ogr\n'), ((8314, 8359), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""CreateFeature failed."""'], {}), "('CreateFeature failed.')\n", (8334, 8359), False, 'import gdaltest\n'), ((8874, 8919), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""CreateFeature failed."""'], {}), "('CreateFeature failed.')\n", (8894, 8919), False, 'import gdaltest\n'), ((9443, 9488), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""CreateFeature failed."""'], {}), "('CreateFeature failed.')\n", (9463, 9488), False, 'import gdaltest\n'), ((10380, 10406), 'ogr.GetDriverByName', 'ogr.GetDriverByName', (['"""GPX"""'], {}), "('GPX')\n", (10399, 10406), False, 'import ogr\n'), ((11021, 11066), 'gdaltest.post_reason', 'gdaltest.post_reason', (['"""CreateFeature failed."""'], {}), "('CreateFeature failed.')\n", (11041, 11066), False, 'import gdaltest\n'), ((12339, 12365), 'ogr.GetDriverByName', 'ogr.GetDriverByName', (['"""GPX"""'], {}), "('GPX')\n", (12358, 12365), False, 'import ogr\n'), ((7595, 7621), 'ogr.GetDriverByName', 'ogr.GetDriverByName', (['"""CSV"""'], {}), "('CSV')\n", (7614, 7621), False, 'import ogr\n')]