0
  B   	ˆl–Ðz¾” ”Ê:”Ê�jã/\ªbÑ¿�þZÁY¹BÓÅp¡ÍùÉ„Ž¸ÿÈ_ŠI|¥�+Wé3ž¯ÀÆ ?÷     	#!/usr/bin/env python
# ******************************************************************************
#  $Id$
#
#  Project:  GDAL
#  Purpose:  Densifies linestrings by a tolerance.
#  Author:   Howard Butler, hobu.inc@gmail.com
#
# ******************************************************************************
#  Copyright (c) 2008, Howard Butler <hobu.inc@gmail.com>
#  Copyright (c) 2021, Idan Miara <idan@miara.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 math
import os
import sys

from osgeo import ogr, osr

ogr.UseExceptions()


def Usage():
    print(
        f"Usage: {sys.argv[0]} -- This is a sample. Read source to know how to use. --"
    )
    return 2


class Translator(object):
    def construct_parser(self):
        from optparse import OptionGroup, OptionParser

        usage = "usage: %prog [options] arg"
        parser = OptionParser(usage)
        g = OptionGroup(parser, "Base options", "Basic Translation Options")
        g.add_option(
            "-i",
            "--input",
            dest="src_filename",
            help="OGR input data source",
            metavar="INPUT",
        )
        g.add_option(
            "-o",
            "--output",
            dest="dst_filename",
            help="OGR output data source",
            metavar="OUTPUT",
        )
        g.add_option(
            "-n",
            "--nooverwrite",
            action="store_false",
            dest="overwrite",
            help="Do not overwrite the existing output file",
        )

        g.add_option(
            "-of",
            "-f",
            "--driver",
            dest="driver_name",
            help='OGR output driver.  Defaults to "ESRI Shapefile"',
            metavar="DRIVER",
        )

        g.add_option(
            "-w",
            "--where",
            dest="where",
            help="""SQL attribute filter -- enclose in quotes "PNAME='Cedar River'" """,
        )
        g.add_option(
            "-s",
            "--spat",
            dest="spat",
            help="""Spatial query extents -- minx miny maxx maxy""",
            type=float,
            nargs=4,
        )
        g.add_option(
            "-l",
            "--layer",
            dest="layer",
            help="""The name of the input layer to translate, if not given, the first layer on the data source is used""",
        )

        g.add_option(
            "-k",
            "--select",
            dest="fields",
            help="""Comma separated list of fields to include -- field1,field2,field3,...,fieldn""",
        )
        g.add_option(
            "-t",
            "--target-srs",
            dest="t_srs",
            help="""Target SRS -- the spatial reference system to project the data to""",
        )
        g.add_option(
            "-a",
            "--assign-srs",
            dest="a_srs",
            help="""Assign SRS -- the spatial