>>> for f in m.query_point([ layer.name for layer in m.layers ].index('world'),51,0):
... print f
...
feature (
f_code:FA001
fac_id:193
id:3147
na2:UK
na3:E
nam:ENGLAND
tile_id:10
)
>>>
fs = m.query_map_point(x,y) # Map (screen) coordinates
for feature in fs:
print feature
TODO: provide interface to feature in Python, at the moment only __str__ implemented which dumps attributes
fixed 'for' loops to work correctly when geom->num_points() < 2
always use prefix increment even for built-in types (good practice!)
e.g ++i
2. agg_renderer.cpp
check for number points in geometries when
applying text/shield_symbolizer.
ds = Shapefile(file="/../..")
for f in ds.features_at_point(Coord(-2,51)):
print f
TODO:
1.access to Feature properties
2.feature_at_point to accept screen coordinates
3.apply hit_test for geometries.
to be rendered. This allows for a large extent (larger than can be
rendered into a single image in memory) to be rendered out as tiles.
Since the full extent is used for the placement calculations text
crossing tile boundaries will be consistent.
This method is a little inefficient when a large number of labels need
placed, an improved method would be to cache these placements between
tiles, but the attached is a start.
c++ users should simple call the render method with a start X and Y
coordinate specified,
for (int TileX = 0;TileX < 5;++TileX)
{
for(int TileY = 0;TileY < 5; ++TileY)
{
int TileSize=250;
int StartX = TileX*TileSize;
int StartY = TileY*TileSize;
Image32 buf(TileSize,TileSize);
agg_renderer<Image32> ren(m,buf,StartX,StartY);
ren.apply();
char name[324];
sprintf(name,"tile_%d_%d.png",TileX,TileY);
ImageUtils::save_to_file(name,"png",buf);
}
}
python users should call render_tile_to_file
for y in range(tile_count_y):
for x in range(tile_count_x):
if not os.path.exists("tiles/%d/%d/" % (map_scale, y)):
os.makedirs("tiles/%d/%d/" % (map_scale, y))
render_tile_to_file(m, x*tile_size, y*tile_size, tile_size, tile_size,
'tiles/%d/%d/%d.png' % (map_scale,y,x), 'png')