- Timestamp:
- 04/28/09 16:58:32 (11 months ago)
- Location:
- tools/routingservice/branches/wrs-2.0
- Files:
-
- 2 added
- 16 modified
- 1 moved
-
data/profiles.xml (modified) (3 diffs)
-
data/resources.xml (modified) (1 diff)
-
data/services.xml (modified) (1 diff)
-
data/templates/geocode/geocode_geojson.st (modified) (2 diffs)
-
data/templates/geocode/geocode_georss_gml.st (modified) (1 diff)
-
data/templates/geocode/geocode_kml.st (modified) (4 diffs)
-
data/templates/geocode/geocode_xls.st (modified) (1 diff)
-
src/WRS.java (modified) (9 diffs)
-
src/handler/DatabaseHandler.java (moved) (moved from tools/routingservice/branches/wrs-2.0/src/handler/PgRoutingHandler.java) (5 diffs, 1 prop)
-
src/handler/HandlerFactory.java (modified) (1 diff)
-
src/handler/ResourceHandler.java (modified) (1 diff)
-
src/model/Resource.java (modified) (5 diffs)
-
src/test (added)
-
src/test/JSONParserTest.java (added)
-
src/util/format/FillerFactory.java (modified) (1 diff)
-
src/util/format/FormatParser.java (modified) (1 diff)
-
src/util/format/JSONParser.java (modified) (3 diffs)
-
src/util/format/ParserFactory.java (modified) (1 diff)
-
src/util/format/TemplateFiller.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/routingservice/branches/wrs-2.0/data/profiles.xml
r312 r314 6 6 <description>My test profile I use for testing</description> 7 7 <parameters> 8 <parameter name="srid_in" type="integer" key="srid" value=" 4326" />8 <parameter name="srid_in" type="integer" key="srid" value="EPSG:4326" /> 9 9 </parameters> 10 10 <resources> 11 11 <rref ref="pgrouting" enabled="true" /> 12 <rref ref="geocoder" enabled="true" /> 12 13 </resources> 13 14 </profile> … … 16 17 <description>My test profile I use for testing</description> 17 18 <parameters> 18 <parameter name="srid_in" type="integer" key="srid" value=" 4326" />19 <parameter name="srid_in" type="integer" key="srid" value="EPSG:4326" /> 19 20 <parameter name="table" type="string" key="table" value="_hcc_algo_shooting_pedestrian" /> 20 21 </parameters> … … 27 28 <description>My test profile I use for testing</description> 28 29 <parameters> 29 <parameter name="srid_in" type="integer" key="srid" value=" 4326" />30 <parameter name="srid_in" type="integer" key="srid" value="EPSG:4326" /> 30 31 <parameter name="table" type="string" key="table" value="_hcc_algo_shooting_tollfree" /> 31 32 </parameters> -
tools/routingservice/branches/wrs-2.0/data/resources.xml
r312 r314 37 37 </query> 38 38 </resource> 39 40 <resource type="database" name="geocoder" 41 title="Geocoder Dumbo server"> 42 <description>PostgreSQL 8.1</description> 43 <parameters> 44 <parameter name="srid" constant="true" type="integer" key="srid" value="EPSG:4326" /> 45 <parameter name="units" constant="true" type="string" key="units" value="dd" /> 46 47 <parameter name="precision" type="integer" key="code"/> 48 <parameter name="x1" type="double" key="x"/> 49 <parameter name="y1" type="double" key="y"/> 50 <parameter name="address" type="string" key="address"/> 51 </parameters> 52 <services> 53 <sref ref="geocode" enabled="true" /> 54 </services> 55 <url>jdbc:postgresql://192.168.20.177:5432/geocoder</url> 56 <user>postgres</user> 57 <password></password> 58 <query> 59 SELECT $output$ FROM $function$($input$) 60 </query> 61 </resource> 39 62 40 63 </resources> -
tools/routingservice/branches/wrs-2.0/data/services.xml
r305 r314 42 42 </out> 43 43 </service> 44 44 <service name="geocode" title="Geocoder"> 45 <description>Geocode a point to an address</description> 46 <templates> 47 <template name="kml" format="xml" url="./data/templates/geocode/geocode_kml.st"/> 48 <template name="geojson" format="json" url="./data/templates/geocode/geocode_geojson.st"/> 49 <template name="xls" format="xml" url="./data/templates/geocode/geocode_xls.st"/> 50 </templates> 51 <in> 52 <parameter key="address" type="string" name="address" /> 53 </in> 54 <out> 55 <parameter key="x1" type="double" name="x1" /> 56 <parameter key="y1" type="double" name="y1" /> 57 <parameter key="address" type="string" name="address" /> 58 <parameter key="precision" type="double" name="precision" /> 59 </out> 60 </service> 61 <service name="locate" title="Locator"> 62 <description>Locates an address by the given point</description> 63 <templates> 64 <template name="kml" format="xml" url="./data/templates/locate/locate_kml.st"/> 65 <template name="geojson" format="json" url="./data/templates/locate/locate_geojson.st"/> 66 <template name="xls" format="xml" url="./data/templates/locate/locate_xls.st"/> 67 </templates> 68 <in> 69 <parameter key="x1" type="double" name="x1" /> 70 <parameter key="y1" type="double" name="y1" /> 71 </in> 72 <out> 73 <parameter key="x1" type="double" name="x1" /> 74 <parameter key="y1" type="double" name="y1" /> 75 <parameter key="address" type="string" name="address" /> 76 <parameter key="precision" type="double" name="precision" /> 77 </out> 78 </service> 45 79 </services> -
tools/routingservice/branches/wrs-2.0/data/templates/geocode/geocode_geojson.st
r313 r314 1 1 { "type": "FeatureCollection", 2 2 "features": [ 3 { "type": "Feature", 4 "geometry": { 3 $parameters:{ p | 4 \{ "type": "Feature", 5 "geometry": \{ 5 6 "type": "Point", 6 "coordinates": [ $p oint$ ]7 },8 "crs": {7 "coordinates": [ $p.x1$ $p.y1$ ] 8 \}, 9 "crs": \{ 9 10 "type": "EPSG", 10 "properties": {"code": "$srid$"} 11 }, 12 "properties": { 13 "address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", 14 "AddressDetails": { 15 "Country": { 16 "CountryNameCode": "US", 17 "AdministrativeArea": { 18 "AdministrativeAreaName": "CA", 19 "SubAdministrativeArea": { 20 "SubAdministrativeAreaName": "Santa Clara", 21 "Locality": { 22 "LocalityName": "Mountain View", 23 "Thoroughfare": { 24 "ThoroughfareName": "1600 Amphitheatre Pkwy" 25 }, 26 "PostalCode": { 27 "PostalCodeNumber": "94043" 28 } 29 } 30 } 31 } 32 }, 33 "Accuracy": 8 34 } 35 } 36 } 11 "properties": \{"code": "$p.srid$"\} 12 \}, 13 "properties": \{ 14 "address": "$p.address$", 15 "AddressDetails": \{ 16 "Country": \{ 17 "CountryNameCode": "$p.country$", 18 "AdministrativeArea": \{ 19 "AdministrativeAreaName": "$p.area$", 20 "SubAdministrativeArea": \{ 21 "SubAdministrativeAreaName": "$p.subarea$", 22 "Locality": \{ 23 "LocalityName": "$p.locality$", 24 "Thoroughfare": \{ 25 "ThoroughfareName": "$p.thouroughfare$" 26 \}, 27 "PostalCode": \{ 28 "PostalCodeNumber": "$p.postal$" 29 \} 30 \} 31 \} 32 \} 33 \}, 34 "Accuracy": "$p.precision$" 35 \} 36 \} 37 \} 38 };separator=","$ 37 39 ], 38 40 "status": { … … 41 43 }, 42 44 "user": { 43 "request_id": "$ request_id$"45 "request_id": "$p.request_id$" 44 46 }, 45 47 } -
tools/routingservice/branches/wrs-2.0/data/templates/geocode/geocode_georss_gml.st
r313 r314 14 14 </author> 15 15 <id>http://this-request-url</id> 16 16 17 $parameters:{ p | 17 18 <entry> 18 19 <title></title> 19 <link href=" http://this-request-url"/>20 <id> http://this-request-url</id>20 <link href="$p.url$"/> 21 <id>$p.url$</id> 21 22 <updated>2005-08-17T07:02:32Z</updated> 22 <summary> </summary>23 <summary>$p.address$</summary> 23 24 24 25 <georss:where> 25 <gml:Point gml:id="p21" srsName="EPSG:$ srid$">26 <gml:pos dimension="2"> 45.256 -71.92</gml:pos>26 <gml:Point gml:id="p21" srsName="EPSG:$p.srid$"> 27 <gml:pos dimension="2">$p.x1$ $p.y1$</gml:pos> 27 28 </gml:Point> 28 29 </georss:where> 29 30 </entry> 31 }$ 30 32 </feed> -
tools/routingservice/branches/wrs-2.0/data/templates/geocode/geocode_kml.st
r313 r314 15 15 </Style> 16 16 17 $parameters:{ p | 17 18 <Placemark> 18 19 <name></name> 19 <address> 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA</address>20 <address>$p.address$</address> 20 21 <description></description> 21 22 <styleUrl>#pointStyle</styleUrl> … … 23 24 <Point> 24 25 <altitudeMode>clampToGround</altitudeMode> 25 <coordinates>$p oint$</coordinates>26 <coordinates>$p.x1$,$p.y1$</coordinates> 26 27 </Point> 27 28 28 29 <AddressDetails Accuracy="8"> 29 30 <Country> 30 <CountryNameCode> US</CountryNameCode>31 <CountryNameCode>$p.country$</CountryNameCode> 31 32 <AdministrativeArea> 32 <AdministrativeAreaName> CA</AdministrativeAreaName>33 <AdministrativeAreaName>$p.area$</AdministrativeAreaName> 33 34 <SubAdministrativeArea> 34 <SubAdministrativeAreaName> Santa Clara</SubAdministrativeAreaName>35 <SubAdministrativeAreaName>$p.subarea$</SubAdministrativeAreaName> 35 36 <Locality> 36 <LocalityName> Mountain View</LocalityName>37 <LocalityName>$p.locality$</LocalityName> 37 38 <Thoroughfare> 38 <ThoroughfareName> 1600 Amphitheatre Pkwy</ThoroughfareName>39 <ThoroughfareName>$p.thouroghfare$</ThoroughfareName> 39 40 </Thoroughfare> 40 41 <PostalCode> 41 <PostalCodeNumber> 94043</PostalCodeNumber>42 <PostalCodeNumber>$p.postal$</PostalCodeNumber> 42 43 </PostalCode> 43 44 </Locality> … … 46 47 </Country> 47 48 </AddressDetails> 49 }$ 48 50 49 51 <ExtendedData xmlns:wrs="http://pgrouting.postlbs.org/wrs/1.1.0"> … … 53 55 </wrs:status> 54 56 <wrs:user> 55 <wrs:request_id>$ request_id$</wrs:request_id>57 <wrs:request_id>$p.request_id$</wrs:request_id> 56 58 </wrs:user> 57 59 </ExtendedData> -
tools/routingservice/branches/wrs-2.0/data/templates/geocode/geocode_xls.st
r284 r314 4 4 xmlns:gml="http://www.opengis.net/gml" 5 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 6 6 7 $parameters:{ p | 7 8 <xls:ResponseHeader sessionID=""/> 8 <xls:Response version="1.2" requestID="$ request_id$" numberOfResponses="1">9 <xls:Response version="1.2" requestID="$p.request_id$" numberOfResponses="1"> 9 10 <xls:GeocodeResponse> 10 11 <xls:GeocodeResponseList numberOfGeocodedAddresses="1"> 11 12 <xls:GeocodedAddress> 12 13 <gml:Point srsName="EPSG:4236"> 13 <gml:pos dimension="2"> 40.123 139.456</gml:pos>14 <gml:pos dimension="2">$p.y1$ $p.x1$</gml:pos> 14 15 </gml:Point> 15 <xls:Address countryCode="" addressee=""> 16 <xls:StreetAddress> 17 <xls:Building number="" 18 subdivision="" 19 buildingName=""/> 20 <xls:Street typePrefix="" 21 typeSuffix="" 22 officialName="" 23 directionalPrefix="" 24 muniOctant="gml:CompassPointEnumeration" 25 /> 26 </xls:StreetAddress> 27 <xls:Place type="CountrySubdivision">ç¥å¥å·ç</xls:Place> 28 <xls:Place type="CountrySecondarySubdivision"></xls:Place> 29 <xls:Place type="Municipality">暪æµåž</xls:Place> 30 <xls:Place type="MunicipalitySubdivision">äžåº</xls:Place> 31 <xls:Place type="choume-banchi-go">1âïŒâïŒ</xls:Place> 32 <xls:PostalCode>245-0001</xls:PostalCode> 33 </xls:Address> 34 <xls:GeocodeMatchCode accuracy="0.0" matchType="go"/> 35 <!-- 36 or 37 --> 16 38 17 <xls:Address countryCode="JA"> 39 <xls:freeFormAddress> ç¥å¥å·ç暪æµåžäžåº1äžç®</xls:freeFormAddress>18 <xls:freeFormAddress>$p.address$</xls:freeFormAddress> 40 19 </xls:Address> 41 <xls:GeocodeMatchCode accuracy=" 0.0" matchType="choume"/>20 <xls:GeocodeMatchCode accuracy="$p.precision$" matchType="$p.match_type$"/> 42 21 </xls:GeocodedAddress> 43 22 </xls:GeocodeResponseList> 44 23 </xls:GeocodeResponse> 45 24 </xls:Response> 25 }$ 46 26 </xls:XLS> 47 27 -
tools/routingservice/branches/wrs-2.0/src/WRS.java
r312 r314 291 291 } 292 292 293 /** 294 * Parses the url. 295 * 296 * @param req 297 * the request to the restlet 298 * 299 * @return the service request 300 * 301 * @throws ArrayIndexOutOfBoundsException 302 * the array index out of bounds exception 303 * @throws InvalidVersionException 304 * the invalid version exception 305 * @throws InvalidProfileException 306 * the invalid profile exception 307 * @throws InvalidServiceException 308 * the invalid service exception 309 * @throws InvalidTemplateException 310 * the invalid template exception 311 */ 293 312 public ServiceRequest parseURL(Request req) 294 313 throws ArrayIndexOutOfBoundsException, InvalidVersionException, … … 339 358 findResource(request); 340 359 341 // TODO parse and pass parameters342 343 360 // Pass parameters from resource to service request 344 361 addParameters(request.getParameters(), request.getResource() … … 410 427 } 411 428 429 /** 430 * Adds the parameters. 431 * 432 * @param parameters 433 * the parameters map 434 * @param toAdd 435 * the map to add to parameters map 436 * @param source 437 * the source of the parameters to add (URL, resource or profile) 438 */ 412 439 private void addParameters(HashMap<String, Parameter> parameters, 413 440 HashMap<String, Parameter> toAdd, String source) 414 441 { 415 // TODO check for ability to override parameters416 417 442 Iterator<String> it = toAdd.keySet().iterator(); 418 443 while (it.hasNext()) … … 467 492 } 468 493 494 /** 495 * Read configuration XML file. 496 * 497 * @param url 498 * the URL of a configuration file 499 * 500 * @return the configuration 501 */ 469 502 public Configuration readConfig(String url) 470 503 { … … 517 550 } 518 551 552 /** 553 * Reads resources configuration file. 554 * 555 * @param url 556 * the URL of a configuration file 557 */ 519 558 private void readResources(String url) 520 559 { … … 582 621 } 583 622 623 /** 624 * Reads profiles configuration file. 625 * 626 * @param url 627 * the URL of a configuration file 628 */ 584 629 private void readProfiles(String url) 585 630 { … … 675 720 } 676 721 722 /** 723 * Reads templates configuration file. 724 * 725 * @param url 726 * the URL of a configuration file 727 */ 677 728 private Template readTemplate(util.service.Template temp) 678 729 { … … 694 745 } 695 746 747 /** 748 * Reads services configuration file. 749 * 750 * @param url 751 * the URL of a configuration file 752 */ 696 753 private void readServices(String url) 697 754 { … … 766 823 } 767 824 825 /** 826 * Find resource by service request. 827 * 828 * @param serviceRequest 829 * the service request 830 */ 768 831 private void findResource(ServiceRequest serviceRequest) 769 832 { -
tools/routingservice/branches/wrs-2.0/src/handler/DatabaseHandler.java
-
Property
svn:mergeinfo set
to
r312 r314 49 49 import com.vividsolutions.jts.io.ParseException; 50 50 51 public class PgRoutingHandler extends ResourceHandler51 public class DatabaseHandler extends ResourceHandler 52 52 { 53 53 private Resource resource; … … 81 81 return new ArrayList(Arrays.asList(p)); 82 82 } 83 }, 84 GEOCODE 85 { 86 ArrayList getParameters() 87 { 88 String[] p = { "address" }; 89 return new ArrayList(Arrays.asList(p)); 90 } 83 91 }; 84 92 … … 86 94 } 87 95 88 public PgRoutingHandler()96 public DatabaseHandler() 89 97 { 90 98 // TODO implement reading functions mapping from a config file … … 93 101 this.functions.put("travel", "tsp_astar_directed_smart"); 94 102 this.functions.put("catch", "driving_distance"); 103 this.functions.put("geocode", "geocode"); 95 104 } 96 105 … … 139 148 out.add(paraMap); 140 149 } 141 142 150 } 143 151 catch (SQLException e) -
Property
svn:mergeinfo set
to
-
tools/routingservice/branches/wrs-2.0/src/handler/HandlerFactory.java
r306 r314 22 22 public static enum Handler 23 23 { 24 DATABASE( PgRoutingHandler.class);24 DATABASE(DatabaseHandler.class); 25 25 26 private Class< ? extends ResourceHandler> mappedClass;26 private Class< ? extends ResourceHandler> mappedClass; 27 27 28 private Handler(Class< ? extends ResourceHandler> h)28 private Handler(Class< ? extends ResourceHandler> h) 29 29 { 30 30 mappedClass = h; -
tools/routingservice/branches/wrs-2.0/src/handler/ResourceHandler.java
r312 r314 89 89 90 90 Geometry point = new WKTReader().read("POINT ("+x+" "+y+")"); 91 Geometry targetPoint = JTS.transform( point, transform);91 Geometry targetPoint = JTS.transform(point, transform); 92 92 93 93 String[] result = {IOHelper.FORMATTER.format(targetPoint.getCoordinate().x), IOHelper.FORMATTER.format(targetPoint.getCoordinate().y)}; -
tools/routingservice/branches/wrs-2.0/src/model/Resource.java
r298 r314 19 19 20 20 import handler.HandlerFactory; 21 import handler. PgRoutingHandler;21 import handler.DatabaseHandler; 22 22 import handler.ResourceHandler; 23 23 … … 52 52 DATABASE(JDBCConnectionPool.class); 53 53 54 private Class< ? extends ObjectPool> poolType;55 56 PoolTypes(Class< ? extends ObjectPool> p)54 private Class< ? extends ObjectPool> poolType; 55 56 PoolTypes(Class< ? extends ObjectPool> p) 57 57 { 58 58 this.poolType = p; … … 63 63 IllegalArgumentException, SecurityException, 64 64 InvocationTargetException 65 { 65 { 66 66 return (ObjectPool) poolType.getConstructors()[0] 67 67 .newInstance(new Object[] { url, user, password }); … … 71 71 private ObjectPool pool; 72 72 73 public Resource(String name, String type, String url, String user, String password, String query) 73 public Resource(String name, String type, String url, String user, 74 String password, String query) 74 75 { 75 76 super(); … … 83 84 try 84 85 { 85 this.pool = PoolTypes.valueOf(type.toUpperCase()).getInstance(url, user, password); 86 this.pool = PoolTypes.valueOf(type.toUpperCase()).getInstance(url, 87 user, password); 86 88 } 87 89 // TODO process the error more carefully -
tools/routingservice/branches/wrs-2.0/src/util/format/FillerFactory.java
r305 r314 31 31 GPX(GPXTemplateFiller.class); 32 32 33 private Class< ? extends TemplateFiller> fillerType;33 private Class< ? extends TemplateFiller> fillerType; 34 34 35 Fillers(Class< ? extends TemplateFiller> p)35 Fillers(Class< ? extends TemplateFiller> p) 36 36 { 37 37 this.fillerType = p; -
tools/routingservice/branches/wrs-2.0/src/util/format/FormatParser.java
r298 r314 29 29 protected enum DataTypes 30 30 { 31 POINTS, LINES, ADDRESS ES, DISTANCE, UOM, LOCALE, CRS, REQUEST_ID, CREDENTIALS;31 POINTS, LINES, ADDRESS, DISTANCE, UOM, LOCALE, CRS, REQUEST_ID, CREDENTIALS; 32 32 } 33 33 -
tools/routingservice/branches/wrs-2.0/src/util/format/JSONParser.java
r306 r314 86 86 String crs = json.getString(key); 87 87 StringTokenizer crsst = new StringTokenizer(crs, ","); 88 88 89 89 Parameter in = new Parameter(); 90 90 in.setName("srid_in"); … … 94 94 95 95 params.add(in); 96 96 97 97 if (crsst.hasMoreTokens()) 98 98 { … … 105 105 params.add(out); 106 106 } 107 break; 108 case ADDRESS: 109 String address = json.getString(key).trim(); 110 Parameter addr = new Parameter(); 111 addr.setName("address"); 112 addr.setSource("url"); 113 addr.setValue(address); 114 addr.setType(ResourceHandler.STRING); 115 params.add(addr); 107 116 break; 108 117 } -
tools/routingservice/branches/wrs-2.0/src/util/format/ParserFactory.java
r298 r314 25 25 null), GPX(null); 26 26 27 private Class< ? extends FormatParser> parserType;27 private Class< ? extends FormatParser> parserType; 28 28 29 Formats(Class< ? extends FormatParser> p)29 Formats(Class< ? extends FormatParser> p) 30 30 { 31 31 this.parserType = p; -
tools/routingservice/branches/wrs-2.0/src/util/format/TemplateFiller.java
r312 r314 67 67 HashMap<String, Parameter> paraMap = it.next(); 68 68 HashMap<String, String> stringMap = new HashMap<String, String>(); 69 Iterator< String> keys = paraMap.keySet().iterator();70 while ( keys.hasNext())69 Iterator<Parameter> params = paraMap.values().iterator(); 70 while (params.hasNext()) 71 71 { 72 String key = keys.next(); 73 Parameter p = paraMap.get(key); 72 Parameter p = params.next(); 74 73 String value = p.getValue(); 75 74 // Geometry string needs to be handled in a special way … … 132 131 value = getGeometryString(points); 133 132 } 134 stringMap.put( key, value);133 stringMap.put(p.getName(), value); 135 134 } 136 135 out.add(stringMap);
