[Commits] r1638 - sandbox/cmoullet/ux/RoutingPanel/ux/widgets
commits at geoext.org
commits at geoext.org
Thu Dec 31 13:35:49 CET 2009
Author: cmoullet
Date: 2009-12-31 13:35:48 +0100 (Thu, 31 Dec 2009)
New Revision: 1638
Modified:
sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
Log:
Add routingServiceType config property in order to allow integration of other routing services
Modified: sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js
===================================================================
--- sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js 2009-12-31 05:46:32 UTC (rev 1637)
+++ sandbox/cmoullet/ux/RoutingPanel/ux/widgets/RoutingPanel.js 2009-12-31 12:35:48 UTC (rev 1638)
@@ -45,7 +45,7 @@
endLocationCombo: null,
/** private: property[proxy]
- * ``Ext.data.ScriptTagProxy`` Proxy to make the cloudmade search request
+ * ``Ext.data.ScriptTagProxy`` Proxy to make the search request
*/
proxy: null,
@@ -62,41 +62,55 @@
*/
lang: 'en',
- /** property[routingVersion]
+ /** api: config[routingServiceType]
+ * Type of routing service used for the computation. Per default: 'cloudmade'
+ */
+ /** private: property[routingServiceType]
+ * Type of routing service used for the computation
+ */
+ routingServiceType: 'cloudmade',
+
+ /** property[routingVersionCloudmade]
* Routing version of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingVersion: null,
+ routingVersionCloudmade: null,
- /** property[routingStatus]
+ /** property[routingStatusCloudmade]
* Routing status of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingStatus: null,
+ routingStatusCloudmade: null,
- /** property[routingStatusMessage]
+ /** property[routingStatusMessageCloudmade]
* Routing status message of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingStatusMessage: null,
+ routingStatusMessageCloudmade: null,
- /** property[routingRouteSummary]
+ /** property[routingRouteSummaryCloudmade]
* Routing route summary of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingRouteSummary: null,
+ routingRouteSummaryCloudmade: null,
- /** property[routingRouteGeometry]
+ /** property[routingRouteGeometryCloudmade]
* Routing route geometry of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingRouteGeometry: null,
+ routingRouteGeometryCloudmade: null,
- /** property[routingRouteInstructions]
+ /** property[routingRouteInstructionsCloudmade]
* Routing route instruction of the routing service, available after an itinerary computation
* See http://developers.cloudmade.com/wiki/routing-http-api/Response_structure
+ * Cloudmade specific
*/
- routingRouteInstructions: null,
+ routingRouteInstructionsCloudmade: null,
/** api: config[routingLayer]
* ``OpenLayers.Layer.Vector`` Layer presenting the routing result geometry. Per default, a layer named "Routing" will be created.
@@ -139,16 +153,17 @@
*/
routingResultPanel: null,
- /** api: config[route_type]
+ /** api: config[route_typeCloudmade]
* Computation route type. Per default: car. Can be 'foot' or 'bicycle'.
*/
- /** private: property[route_type]
+ /** private: property[route_typeCloudmade]
* Computation route type. Per default: car.
*/
- route_type: 'car',
+ route_typeCloudmade: 'car',
/** api: config[cloudmadeKey]
* Cloudmade key used for the routing and geocoding services
+ * Cloudmade specific
*/
cloudmadeKey: null,
@@ -214,7 +229,7 @@
/** private: method[initComponent]
* Private initComponent override.
- * Create two events:
+ * Create two events:
* - routingcomputed
* - beforeroutingcomputed
*/
@@ -491,7 +506,7 @@
this.routingResultPanel.html = OpenLayers.i18n('Computation ongoing....');
this.routingResultPanel.body.update(this.routingResultPanel.html);
var newUrl = this.startLocationCombo.locationString + ',' + this.endLocationCombo.locationString;
- newUrl = newUrl + "/" + this.route_type + ".js?lang=" + this.lang;
+ newUrl = newUrl + "/" + this.route_typeCloudmade + ".js?lang=" + this.lang;
this.proxy.url = "http://routes.cloudmade.com/" + this.cloudmadeKey + "/api/0.3/" + newUrl;
}, this);
@@ -540,47 +555,51 @@
* Compute the itinerary and assign the results
*/
getItinerary: function() {
- this.routingStore = new Ext.data.Store({
- proxy: this.proxy,
- reader: new Ext.data.JsonReader({
- root: 'version',
- fields: [
- {
- name: 'total_length'
- }
- ]
+ if (this.routingServiceType == 'cloudmade') {
+ this.routingStore = new Ext.data.Store({
+ proxy: this.proxy,
+ reader: new Ext.data.JsonReader({
+ root: 'version',
+ fields: [
+ {
+ name: 'total_length'
+ }
+ ]
- })
- });
+ })
+ });
- this.routingStore.on(
- 'load', function(store) {
- this.routingVersion = store.reader.jsonData.version;
- this.routingStatus = store.reader.jsonData.status;
- if (store.reader.jsonData.status_message) {
- this.routingStatusMessage = store.reader.jsonData.status_message;
- }
- if (store.reader.jsonData.route_summary) {
- this.routingRouteSummary = store.reader.jsonData.route_summary;
- }
- if (store.reader.jsonData.route_geometry) {
- this.routingRouteGeometry = store.reader.jsonData.route_geometry;
- }
- if (store.reader.jsonData.route_instructions) {
- this.routingRouteInstructions = store.reader.jsonData.route_instructions;
- }
- if (this.routingStatus == '0') {
- this.drawRoute();
- this.routingResultPanel.html = OpenLayers.i18n('Total length: ') + Math.round(this.routingRouteSummary.total_distance / 1000) + ' [km]';
- this.routingResultPanel.body.update(this.routingResultPanel.html);
- } else {
- this.routingResultPanel.html = this.routingStatusMessage;
- this.routingResultPanel.body.update(this.routingResultPanel.html);
- }
- this.fireEvent('routingcomputed', this);
- }, this
- );
- this.routingStore.load();
+ this.routingStore.on(
+ 'load', function(store) {
+ this.routingVersionCloudmade = store.reader.jsonData.version;
+ this.routingStatusCloudmade = store.reader.jsonData.status;
+ if (store.reader.jsonData.status_message) {
+ this.routingStatusMessageCloudmade = store.reader.jsonData.status_message;
+ }
+ if (store.reader.jsonData.route_summary) {
+ this.routingRouteSummaryCloudmade = store.reader.jsonData.route_summary;
+ }
+ if (store.reader.jsonData.route_geometry) {
+ this.routingRouteGeometryCloudmade = store.reader.jsonData.route_geometry;
+ }
+ if (store.reader.jsonData.route_instructions) {
+ this.routingRouteInstructionsCloudmade = store.reader.jsonData.route_instructions;
+ }
+ if (this.routingStatusCloudmade == '0') {
+ this.drawRoute();
+ this.routingResultPanel.html = OpenLayers.i18n('Total length: ') + Math.round(this.routingRouteSummaryCloudmade.total_distance / 1000) + ' [km]';
+ this.routingResultPanel.body.update(this.routingResultPanel.html);
+ } else {
+ this.routingResultPanel.html = this.routingStatusMessageCloudmade;
+ this.routingResultPanel.body.update(this.routingResultPanel.html);
+ }
+ this.fireEvent('routingcomputed', this);
+ }, this
+ );
+ this.routingStore.load();
+ } else {
+ alert('routing service ' + this.routingServiceType + ' not supported. Patch welcome !');
+ }
},
/** private: method[drawRoute]
@@ -588,13 +607,16 @@
*/
drawRoute: function() {
var pointList = [];
- var newPoint = null;
- for (var i = 0; i < this.routingRouteGeometry.length; i++) {
- newPoint = new OpenLayers.Geometry.Point(this.routingRouteGeometry[i][1],
- this.routingRouteGeometry[i][0]);
- newPoint.transform(this.routingProjection,
- this.map.getProjectionObject());
- pointList.push(newPoint);
+
+ if (this.routingServiceType == 'cloudmade') {
+ var newPoint = null;
+ for (var i = 0; i < this.routingRouteGeometryCloudmade.length; i++) {
+ newPoint = new OpenLayers.Geometry.Point(this.routingRouteGeometryCloudmade[i][1],
+ this.routingRouteGeometryCloudmade[i][0]);
+ newPoint.transform(this.routingProjection,
+ this.map.getProjectionObject());
+ pointList.push(newPoint);
+ }
}
if (this.routingPathFeature) {
More information about the Commits
mailing list