WebRouting service configuration
Before being able to start the service change the settings in configuration.xml.
Main
<?xml version="1.0" encoding="ISO-8859-1"?> <restlet> <port>[port]</port> <log mode="[1|2|3]">./log/access.log</log> <providers> <provider name="[name]" title="[Add a title]"> [...] </provider> <!-- Example(s) --> <provider name="[osm]" title="[OpenStreetMap]"> [...] </provider> </providers> </restlet>
- port: The port number which WRS will use (ie. 8182)
- log: The log file with log level 0,1 or 2 (0: default mode, 1: debug mode, 2: full mode)
- providers: WRS can run services of several "providers". A provider can be a data provider like OpenStreetMap? for example. The "name" attribute specifies the provider name in the URL.
Provider
[...] <provider name="[name]" title="[Add a title]"> <description>[Provider description]</description> <services> <service name="[name]" title="[Add a title]" enable="true"> [...] </service> <!-- Example(s) --> <service name="shortest_path" title="Shortest Path" enable="true"> [...] </service> <service name="driving_distance" title="Driving Distance" enable="false"> [...] </service> <service name="security" title="Security" enable="true"> [(1)] </service> </services> </provider> [...]
- services: WRS can run several services within every provider. The "name" attribute specifies the service name in the URL.
- (1): See Security Service configuration for more details.
Service
[...] <services> <service name="[name]" title="[Add a title]" enable="true"> <description>[Service description]</description> <connection driver="org.postgresql.Driver"> <url>jdbc:postgresql://[hostname]:[port]/[database]</url> <user>[username]</user> <password>[password]</password> </connection> <projection srid="[srid]" units="[meter|degrees]"></projection> <limit distance="[distance]" /> <sql> <query transformProjectionIn="false" transformProjectionOut="false">[query example 1]</query> <query transformProjectionIn="false" transformProjectionOut="true" >[query example 2]</query> <query transformProjectionIn="true" transformProjectionOut="false">[query example 3]</query> <query transformProjectionIn="true" transformProjectionOut="true" >[query example 4]</query> </sql> <parameters> <parameter name="point_start" type="text" codename="start" required="true" /> <parameter name="point_end" type="text" codename="end" required="true" /> <parameter name="sridInput" type="integer" codename="sridIn" required="false" /> <parameter name="sridOutput" type="integer" codename="sridOut" required="false" /> <parameter name="bbox" type="integer" codename="bbox" required="false" default="0.015" /> <parameter name="request_id" type="text" codename="request_id" required="false" /> </parameters> <formats> <format name="gml" input="true" output="true" template="multilinestring_gml" /> <format name="xml" input="false" output="true" template="multilinestring_xml" /> <format name="html" input="false" output="true" template="multilinestring_html" /> <format name="geojson" input="true" output="true" template="multilinestring_geojson" /> <format name="lonlat" input="true" output="false" /> <format name="wkt" input="true" output="true" template="multilinestring_wkt" /> <format name="kml" input="true" output="true" template="multilinestring_kml" srid="4326" /> </formats> </service> </services> [...]
- srid: Projection SRID
- units: Should be "meter" or "degrees"
- limit: For shortest path search WRS will check the euclidean distance between your start and end point and check against the distance limit. (Should have the same dimension as projection unit.)
- sql: Defines the SQL queries. (not sure if the "transformation" is such a clever approach)
- query: For Shooting Star this could be:
- parameters: Defines the GET/POST atributes. ("codename" is the URL attribute)
- formats: Defines the possible output formats with related templates.
Example queries
Shooting Star
# query example 1 SELECT gid, AsText(the_geom) AS wkt FROM shootingstar_sp_smart('<table>', $sonStartX$, $sonStartY$, $sonEndX$, $sonEndY$,$saBoxSize$,'length','to_cost',false,false) # query example 2 SELECT gid, AsText(transform(setSRID(the_geom,$sridProvider$), $sridOut$)) AS wkt FROM shootingstar_sp_smart('<table>', $sonStartX$, $sonStartY$, $sonEndX$, $sonEndY$, $saBoxSize$,'length','to_cost',false,false) # query example 3 SELECT gid, AsText(the_geom) AS wkt FROM shootingstar_sp_smart('<table>', X(transform(GeometryFromText('POINT($sonStartX$ $sonStartY$)',$sridIn$),$sridProvider$)), Y(transform(GeometryFromText('POINT($sonStartX$ $sonStartY$)',$sridIn$),$sridProvider$)), X(transform(GeometryFromText('POINT($sonEndX$ $sonEndY$)',$sridIn$),$sridProvider$)), Y(transform(GeometryFromText('POINT($sonEndX$ $sonEndY$)',$sridIn$),$sridProvider$)), $saBoxSize$,'length','to_cost',false,false) # query example 4 SELECT gid, AsText(transform(setSRID(the_geom,$sridProvider$), $sridOut$)) AS wkt FROM shootingstar_sp_smart('<table>', X(transform(GeometryFromText('POINT($sonStartX$ $sonStartY$)',$sridIn$),$sridProvider$)), Y(transform(GeometryFromText('POINT($sonStartX$ $sonStartY$)',$sridIn$),$sridProvider$)), X(transform(GeometryFromText('POINT($sonEndX$ $sonEndY$)',$sridIn$),$sridProvider$)), Y(transform(GeometryFromText('POINT($sonEndX$ $sonEndY$)',$sridIn$),$sridProvider$)), $saBoxSize$,'length','to_cost',false,false)