PR fixes.
This commit is contained in:
parent
f2ecf5a0a7
commit
5c492dfada
3 changed files with 19 additions and 24 deletions
|
@ -42,9 +42,9 @@ with open(options.source) as logfile:
|
|||
break
|
||||
|
||||
# Print stats.
|
||||
print "Found {} points".format(len(points))
|
||||
print "There are {} points with no external mwm, and {} points if features that have many border intersections". format(
|
||||
len([a for a in points if a[2] == 2]), len([a for a in points if a[2] == 1])
|
||||
print "Found {0} points".format(len(points))
|
||||
print "Found {0} ways that do not lead to the external mwm and {1} roads that crossing the border several times.". format(
|
||||
len(filter(lambda a: a[2] == 2, points)), len(filter(lambda a: a[2] == 1, points))
|
||||
)
|
||||
|
||||
# Commit to the database
|
||||
|
@ -52,9 +52,9 @@ conn = psycopg2.connect(options.connection)
|
|||
cursor = conn.cursor()
|
||||
|
||||
if options.truncate:
|
||||
print "Truncating old data..."
|
||||
print "Truncating old data..."
|
||||
cursor.execute("TRUNCATE TABLE points")
|
||||
|
||||
cursor.execute("INSERT into points (geom, type) VALUES {}".format(",".
|
||||
join(["(ST_GeomFromText('POINT({} {})', 4326), {})".format(*p) for p in points])))
|
||||
for p in points:
|
||||
cursor.execute("INSERT into points (geom, type) VALUES (ST_GeomFromText('POINT(%s %s)', 4326), %s)", p)
|
||||
conn.commit()
|
||||
|
|
|
@ -23,7 +23,9 @@ def hello_world():
|
|||
|
||||
@app.route('/www/<path:path>')
|
||||
def send_js(path):
|
||||
return send_from_directory('../www/', path)
|
||||
if config.DEBUG:
|
||||
return send_from_directory('../www/', path)
|
||||
abort(404)
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
|
@ -101,16 +103,13 @@ def query_routing_points():
|
|||
ymin = request.args.get('ymin')
|
||||
ymax = request.args.get('ymax')
|
||||
cur = g.conn.cursor()
|
||||
cur.execute('''SELECT ST_AsText(geom), type
|
||||
cur.execute('''SELECT ST_X(geom), ST_Y(geom), type
|
||||
FROM points
|
||||
WHERE geom && ST_MakeBox2D(ST_Point(%s, %s), ST_Point(%s, %s)
|
||||
);''', (xmin, ymin, xmax, ymax))
|
||||
result = []
|
||||
for rec in cur:
|
||||
points = rec[0].split()
|
||||
lat = float(points[0].split('(')[1])
|
||||
lon = float(points[1].split(')')[0])
|
||||
result.append({ 'lat': lat, 'lon': lon, 'type': rec[1] })
|
||||
result.append({ 'lon': rec[0], 'lat': rec[1], 'type': rec[2] })
|
||||
return jsonify(features=result)
|
||||
|
||||
@app.route('/tables')
|
||||
|
|
|
@ -20,7 +20,7 @@ function init() {
|
|||
{ attribution: '© GIScience Heidelberg' }).addTo(map);
|
||||
bordersLayer = L.layerGroup();
|
||||
map.addLayer(bordersLayer);
|
||||
routingGroup = new L.FeatureGroup();
|
||||
routingGroup = new L.FeatureGroup();
|
||||
|
||||
map.on('moveend', function() {
|
||||
if( map.getZoom() >= 5 )
|
||||
|
@ -99,8 +99,7 @@ function updateBorders() {
|
|||
'ymax': b.getNorth()
|
||||
},
|
||||
success: processRouting,
|
||||
dataType: 'json',
|
||||
simplified: simplified
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
if( oldBordersLayer != null && OLD_BORDERS_NAME ) {
|
||||
|
@ -124,16 +123,13 @@ routingTypes = {1: "Border and feature are intersecting several times.",
|
|||
2: "Unknown outgoing feature."};
|
||||
|
||||
function processRouting(data) {
|
||||
routingGroup.clearLayers();
|
||||
map.removeLayer(routingGroup);
|
||||
map.removeLayer(routingGroup);
|
||||
routingGroup.clearLayers();
|
||||
for( var f = 0; f < data.features.length; f++ ) {
|
||||
marker = L.marker([data.features[f]["lon"], data.features[f]["lat"]]).addTo(map);
|
||||
marker.bindPopup(routingTypes[data.features[f]["type"]], {
|
||||
showOnMouseOver: true
|
||||
});
|
||||
routingGroup.addLayer(marker);
|
||||
}
|
||||
map.addLayer(routingGroup);
|
||||
marker = L.marker([data.features[f]["lat"], data.features[f]["lon"]]).addTo(routingGroup);
|
||||
marker.bindPopup(routingTypes[data.features[f]["type"]], {showOnMouseOver: true});
|
||||
}
|
||||
map.addLayer(routingGroup);
|
||||
}
|
||||
|
||||
function processResult(data) {
|
||||
|
|
Loading…
Add table
Reference in a new issue