flake8
This commit is contained in:
parent
5f1f20a16a
commit
db18a17f66
@ -1,18 +1,22 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
from decimal import Decimal as Dec
|
from decimal import Decimal as Dec
|
||||||
|
|
||||||
|
|
||||||
class Deg(namedtuple('Deg', ['deg', 'mm', 'ss'])):
|
class Deg(namedtuple('Deg', ['deg', 'mm', 'ss'])):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%03d-%02d-%.1f" % (self.deg, self.mm, self.ss)
|
return "%03d-%02d-%.1f" % (self.deg, self.mm, self.ss)
|
||||||
|
|
||||||
|
|
||||||
def guess(inp):
|
def guess(inp):
|
||||||
if isinstance(inp, str) and '-' in inp:
|
if isinstance(inp, str) and '-' in inp:
|
||||||
deg, mm, ss = inp.split('-')
|
deg, mm, ss = inp.split('-')
|
||||||
ddeg, dmm, dss = Dec(deg), Dec(mm), Dec(ss)
|
ddeg, dmm, dss = Dec(deg), Dec(mm), Dec(ss)
|
||||||
return ddeg + dmm/60 + dss/3600
|
return ddeg + dmm/60 + dss/3600
|
||||||
else:
|
else:
|
||||||
return Dec(instr)
|
return Dec(inp)
|
||||||
|
|
||||||
|
|
||||||
def hms(deg):
|
def hms(deg):
|
||||||
assert isinstance(deg, Dec)
|
assert isinstance(deg, Dec)
|
||||||
|
@ -5,6 +5,7 @@ import rtree
|
|||||||
import os
|
import os
|
||||||
from osgeo import ogr
|
from osgeo import ogr
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
driver = ogr.GetDriverByName('gpkg')
|
driver = ogr.GetDriverByName('gpkg')
|
||||||
|
|
||||||
@ -13,7 +14,11 @@ def main():
|
|||||||
srs = inLayer.GetSpatialRef()
|
srs = inLayer.GetSpatialRef()
|
||||||
outDataSource = driver.CreateDataSource(sys.argv[2])
|
outDataSource = driver.CreateDataSource(sys.argv[2])
|
||||||
outLayerName, _ = os.path.splitext(os.path.basename(sys.argv[2]))
|
outLayerName, _ = os.path.splitext(os.path.basename(sys.argv[2]))
|
||||||
outLayer = outDataSource.CreateLayer(outLayerName, srs, geom_type=ogr.wkbLineString)
|
outLayer = outDataSource.CreateLayer(
|
||||||
|
outLayerName,
|
||||||
|
srs,
|
||||||
|
geom_type=ogr.wkbLineString
|
||||||
|
)
|
||||||
|
|
||||||
points = extract_layer_points(inLayer)
|
points = extract_layer_points(inLayer)
|
||||||
path = greedy_path(points)
|
path = greedy_path(points)
|
||||||
@ -36,6 +41,7 @@ def extract_layer_points(layer):
|
|||||||
points[i] = (p[0], p[1])
|
points[i] = (p[0], p[1])
|
||||||
return points
|
return points
|
||||||
|
|
||||||
|
|
||||||
def greedy_path(points):
|
def greedy_path(points):
|
||||||
"""Given a dict of points, return a "greedy" path between them.
|
"""Given a dict of points, return a "greedy" path between them.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user