[OSM-dev] Map rendering code... API or database direct?
Raphaël Jacquot
sxpert at esitcom.org
Thu Mar 30 15:30:44 BST 2006
immanuel.scholz at gmx.de wrote:
> Yes, it is. So if you want a fast way to get all segments that may be needed
> to draw the current tile, you should not use the above but Richard's former
> suggestion (in some other mail).
>
> If you are only interesting in line segments that have one node within the
> current tile (as you drawed with ascii before), then use the statement above.
>
> Ciao, Imi.
>
> PS: Remeber: The best solution is to fire up a trac ticket (or verify whether
> there is already one) to have the API map request return correctly all line
> segments necessary. Then use the API instead of writing your own SQL. ;-)
I just tested, and found the soultion readily available in postgres...
osm=# select * from points;
id | p
----+-------------
1 | (1.5,2.5)
2 | (2.5,2.5)
3 | (1.25,1.75)
4 | (1.75,1.25)
5 | (2.5,1)
(5 rows)
osm=# select * from segments;
id | point_a | point_b
----+---------+---------
1 | 1 | 2
2 | 1 | 5
3 | 3 | 4
4 | 3 | 5
(4 rows)
and a view like :
osm=# \d segmentcoords
View "public.segmentcoords"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
s | lseg |
View definition:
SELECT segments.id, lseg(point_a.p, point_b.p) AS s
FROM segments, points point_a, points point_b
WHERE segments.point_a = point_a.id AND segments.point_b = point_b.id;
we can easily get :
osm=# select * from segmentcoords where s ?# box('(1,2),(2,1)');
id | s
----+---------------------------
2 | [(1.5,2.5),(2.5,1)]
3 | [(1.25,1.75),(1.75,1.25)]
4 | [(1.25,1.75),(2.5,1)]
(3 rows)
does that implements what you want ?
-- Raphaël
More information about the dev
mailing list