Commit 54593243 authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

First parameters used in tools.py

parent 91df81e1
# -*- coding: utf-8 -*-
'''
Created on May 27, 2013
@author: vanosten
'''
class Parameters(object):
'''
Central place to store parameters / settings / variables in osm2city.
TODO: load from file and write to file
'''
def __init__(self):
'''
Constructor. For the time being replace the default values with your own before running the modules in osm2city.
'''
# The boundary of the scenery in degrees (use "." not ","). The example below is from LSZR.
self.boundary_west = 9.54
self.boundary_south = 47.48
self.boundary_east = 9.58
self.boundary_north = 47.50
# The distance between raster points for the derived elevation map (x is horizontal, y is vertical)
self.elev_raster_x = 10
self.elev_raster_y = 10
......@@ -16,6 +16,8 @@ stats = None
import vec2d
import coordinates
from parameters import Parameters
class Interpolator(object):
"""load elevation data from file, interpolate"""
def __init__(self, filename, fake=False):
......@@ -70,23 +72,17 @@ class Interpolator(object):
def shift(self, h):
self.h += h
#11.16898,47.20837,11.79108,47.38161
def raster_glob(cmin, cmax):
from vec2d import vec2d
# center = (cmax - cmin)
# center.x *= 0.5
# center.y *= 0.5
def raster_glob(params):
cmin = vec2d.vec2d(params.boundary_west, params.boundary_south)
cmax = vec2d.vec2d(params.boundary_east, params.boundary_north)
center = (cmin + cmax) * 0.5
transform = coordinates.Transformation((center.x, center.y), hdg = 0)
lmin = vec2d(transform.toLocal(cmin.list()))
lmax = vec2d(transform.toLocal(cmax.list()))
lmin = vec2d.vec2d(transform.toLocal(cmin.__iter__()))
lmax = vec2d.vec2d(transform.toLocal(cmax.__iter__()))
delta = (lmax - lmin)*0.5
# dx = 5000
# dy = 4000
print "bla", delta
raster(transform, "elev.in", -delta.x, -delta.y, 2*delta.x, 2*delta.y, step_x=10, step_y=10)
print "Distance from middle to boundary in meters (x, y):", delta
raster(transform, "elev.in", -delta.x, -delta.y, 2*delta.x, 2*delta.y, params.elev_raster_x, params.elev_raster_y)
def raster(transform, fname, x0, y0, size_x=1000, size_y=1000, step_x=5, step_y=5):
# --- need $FGDATA/Nasal/elev.nas and elev.in
......@@ -238,6 +234,6 @@ def init():
print "tools: init", stats
if __name__ == "__main__":
# W,S,E,N coordinates
raster_glob(vec2d.vec2d(11.16898,47.20837), vec2d.vec2d(11.79108,47.38161))
params = Parameters()
raster_glob(params)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment