0
  Y   /ˆl–Ðz¾” ”Ê:”Ê�jã/\ªbÑ¿�þYœY¹BÓÅp¡ÍùÉ„›x_Î_ŠI|¥�+Wé3ž¯a–Ðz¾”d
i?u8 Aq—n	õ1hßÍ 1&    /#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###############################################################################
# $Id$
#
# Project:  OGR Python samples
# Purpose:  Create OGR VRT from source datasource
# Author:   Frank Warmerdam, warmerdam@pobox.com
#
###############################################################################
# Copyright (c) 2009, Frank Warmerdam <warmerdam@pobox.com>
# Copyright (c) 2009-2014, Even Rouault <even dot rouault at spatialys.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.
###############################################################################

import os.path
import sys

from osgeo import gdal, ogr

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


def GeomType2Name(typ):
    flat_type = ogr.GT_Flatten(typ)
    dic = {
        ogr.wkbUnknown: ("wkbUnknown", "25D"),
        ogr.wkbPoint: ("wkbPoint", "25D"),
        ogr.wkbLineString: ("wkbLineString", "25D"),
        ogr.wkbPolygon: ("wkbPolygon", "25D"),
        ogr.wkbMultiPoint: ("wkbMultiPoint", "25D"),
        ogr.wkbMultiLineString: ("wkbMultiLineString", "25D"),
        ogr.wkbMultiPolygon: ("wkbMultiPolygon", "25D"),
        ogr.wkbGeometryCollection: ("wkbGeometryCollection", "25D"),
        ogr.wkbNone: ("wkbNone", ""),
        ogr.wkbLinearRing: ("wkbLinearRing", ""),
        ogr.wkbCircularString: ("wkbCircularString", "Z"),
        ogr.wkbCompoundCurve: ("wkbCompoundCurve", "Z"),
        ogr.wkbCurvePolygon: ("wkbCurvePolygon", "Z"),
        ogr.wkbMultiCurve: ("wkbMultiCurve", "Z"),
        ogr.wkbMultiSurface: ("wkbMultiSurface", "Z"),
        ogr.wkbCurve: ("wkbCurve", "Z"),
        ogr.wkbSurface: ("wkbSurface", "Z"),
        ogr.wkbPolyhedralSurface: ("wkbPolyhedralSurface", "Z"),
        ogr.wkbTIN: ("wkbTIN", "Z"),
        ogr.wkbTriangle: ("wkbTriangle", "Z"),
    }
    ret = dic[flat_type][0]
    if flat_type != typ:
        if ogr.GT_HasM(typ):
            if ogr.GT_HasZ(typ):
                ret += "ZM"
            else:
                ret += "M"
        else:
            ret += dic[flat_type][1]
    return ret


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


def Esc(x):
    return gdal.EscapeString(x, gdal.CPLES_XML)


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


def Usage():
    print("Usage: ogr2vrt.py [-relative] [-schema] [-feature_count] [-extent]")
    print("                  in_datasource out_vrtfile [layers]")
    print("")
    return 2


def main(argv=sys.argv):
    infile = None
    outfile = None
    layer_list = []
    relative = "0"
    schema = 0
    feature_count = 0
    extent = 0
    openoptions = []

    argv = gdal.GeneralCmdLineProcessor(argv)
    if argv is None:
        return 0

    i = 1
    while i < len(argv):
        arg = argv[i]

        if arg == "-relative":
            relative = "1"

        elif arg == "-schema":
            schema = 1

        elif arg == "