[OSM-dev] Map rendering code... API or database direct?

Raphaël Jacquot sxpert at esitcom.org
Thu Mar 30 13:38:40 BST 2006


Richard Fairhurst wrote:
> Tom wrote:
> 
>> On 3/30/06, Raphaël Jacquot <sxpert at esitcom.org> wrote:
>>
>>>
>>> there is another better way yet, available at the sql level...
>>> select all line segments that have a "foot" in the tile you're
>>> interested in.
>>
>>
>> No, the problem is that some segments don't have any "feet" in the 
>> current tile.
> 
> 
> SELECT id,path FROM segments WHERE
>    ((xmin BETWEEN $bbox_xmin AND $bbox_xmax) OR
>     (xmax BETWEEN $bbox_xmin AND $bbox_xmax) OR
>     (xmin<$bbox_xmin AND xmax>$bbox_xmax)) AND
>    ((ymin BETWEEN $bbox_ymin AND $bbox_ymax) OR
>     (ymax BETWEEN $bbox_ymin AND $bbox_ymax) OR
>     (ymin<$bbox_ymin AND ymax>$bbox_ymax))
> 
> where xmin, xmax, ymin and ymax are the bounding box of each segment, 
> and $bbox_xmin, $bbox_xmax etc. are the bounding box of the current map 
> view (tile).

with postgresql 8.1 (that includes the postgis geometric objects), it's 
even easier :D

SELECT * FROM segments WHERE
	( point_a @ box('(x1,y1),(x2,y2)') ) OR
	( point_b @ box('(x1,y1),(x2,y2)') )



> Richard
> 
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/dev
> 





More information about the dev mailing list