Skip to content

Commit 36b0ae1

Browse files
committed
Merge pull request #118 from plepe/standalone-process-id
Mode Standalone: process specified ID
2 parents 2eebb55 + e17c1af commit 36b0ae1

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.creole

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.11 release upcoming
2+
* Mode standalone: specify ID or list of IDs instead of a bounding box
3+
14
0.10.4 release 2015-03-11
25
* DB/Overpass: set max allowed memory by config option {{{db.overpass-memory}}}
36
* DB/Overpass: load full response at once; this greatly improves performance, but needs more memory.

doc/API.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ optional arguments:
5252
Process the map from the specified bounding box as
5353
min_lon,min_lat,max_lon,max_lat in WGS-84. (default:
5454
whole database)
55+
-o ID [ID ...], --id ID [ID ...]
56+
Instead of processing all objects in the specified
57+
bounding box, process only the given object(s).
5558
-s SCALE, --scale SCALE
5659
Process map at a specified scale denominator. If
5760
z<zoom> syntax (e.g. "z15") is used, the zoom levels
@@ -73,6 +76,7 @@ scale | Process map at a specified scale denominator.
7376
zoom | zoom level of standard tile based map (projection 900913)
7477
x, y | x/y tiles as with images (jpg/png), requires parameter z or zoom
7578
z | zoom level in combination with x/y tiles. If a different tilesize (e.g. 512 or 1024) is used, the zoom level will be adapted automatically. With tilesize 256, zoom and z are equal.
79+
id | Instead of processing all objects in the specified bounding box, process only the given object(s). For multiple objects, pass the parameter multiple times.
7680
tilesize | the tilesize when using x/y tiles (default: 256)
7781
lang | Use the given language code (e.g. "en" or "de") for language dependend instructions. Default: the first value of the HTTP Accept-Language header.
7882
srs | ID of projection of output coordinates (default: 4326).

pgmapcss/compiler/compile_function_match.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def compile_function_match(stat):
9696
plan = plpy.prepare('select ST_SetSRID(ST_MakeBox2D(ST_Point($1, $2), ST_Point($3, $4)), $5) as bounds', ['float', 'float', 'float', 'float', 'int'])
9797
res = plpy.execute(plan, [float(b) for b in bbox] + [ parameters['in.srs'] if 'in.srs' in parameters else parameters['srs'] ])
9898
_bbox = res[0]['bounds']
99+
elif type(bbox) == set:
100+
_bbox = None
99101
else:
100102
_bbox = bbox
101103
@@ -127,14 +129,16 @@ def compile_function_match(stat):
127129
128130
'''.format(**replacement)
129131

130-
func = "objects_bbox(render_context.get('bbox'), db_selects, {})"
132+
ret += "if type(bbox) == set:\n"
133+
ret += " src = objects_by_id(bbox, {})\n"
134+
ret += "else:\n"
135+
ret += " src = objects_bbox(render_context.get('bbox'), db_selects, {})\n"
136+
131137
if stat['config'].get('debug.profiler', False):
132138
ret += "time_qry_start = datetime.datetime.now() # profiling\n"
133-
ret += "src = list(" + func + ")\n"
139+
ret += "src = list(src)\n"
134140
ret += "time_qry_stop = datetime.datetime.now() # profiling\n"
135141
ret += "plpy.warning('querying db objects took %.2fs' % (time_qry_stop - time_qry_start).total_seconds())\n"
136-
else:
137-
ret += "src = " + func + "\n"
138142

139143
ret += '''\
140144

pgmapcss/mode/standalone/footer.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ if __name__ == '__main__':
6060
]
6161
parameters['in.srs'] = 4326
6262

63+
if params.getvalue("id"):
64+
bounds = set(params.getlist("id"))
65+
6366
if params.getvalue("scale"):
6467
scale_denom = float(params.getvalue("scale"))
6568

@@ -104,6 +107,9 @@ if __name__ == '__main__':
104107
help='Process the map from the specified bounding box as min_lon,min_lat,max_lon,max_lat in WGS-84. (default: whole database)'
105108
)
106109

110+
parser.add_argument('-o', '--id', dest='id', nargs='+',
111+
help='Instead of processing all objects in the specified bounding box, process only the given object(s).')
112+
107113
parser.add_argument('-s', '--scale', dest='scale',
108114
default='2000',
109115
help='Process map at a specified scale denominator. If z<zoom> syntax (e.g. "z15") is used, the zoom levels of projection 900913 are used.'
@@ -129,6 +135,10 @@ if __name__ == '__main__':
129135
if len(bounds) != 4:
130136
print("Error parsing bounds, expecting four numbers.")
131137
sys.exit(1)
138+
139+
elif args.id:
140+
bounds = set(args.id)
141+
132142
else:
133143
bounds = None
134144

0 commit comments

Comments
 (0)