Skip to content

Commit

Permalink
Merge pull request #10 from IGNF/fix-invert-coordinates
Browse files Browse the repository at this point in the history
geographical coordinates management
  • Loading branch information
gcebelieu committed May 30, 2016
2 parents 7dcec5d + c080aa8 commit 10b3654
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 199 deletions.
221 changes: 139 additions & 82 deletions dist/GpServices-debug.js

Large diffs are not rendered by default.

71 changes: 63 additions & 8 deletions dist/GpServices-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* copyright IGN
* @author IGN
* @version 1.0.0-beta2
* @date 2016-05-18
* @date 2016-05-27
*
*/
/*!
Expand Down Expand Up @@ -2349,31 +2349,45 @@ ServicesAutoConfResponseModelAutoConfResponse = function () {
getLayersConf: function (apiKey) {
var layers = {};
var layersIdArray = this.getLayersId(apiKey);
for (var i = 0; i < layersIdArray.length; i++) {
var lyrId = layersIdArray[i];
layers[lyrId] = this.layers[lyrId];
if (layersIdArray) {
for (var i = 0; i < layersIdArray.length; i++) {
var lyrId = layersIdArray[i];
layers[lyrId] = this.layers[lyrId];
}
}
return layers;
},
getLayerConf: function (layerId) {
if (!this.layers) {
return;
}
return this.layers[layerId];
},
getTileMatrixSets: function () {
return this.tileMatrixSets;
},
getTMSConf: function (tmsID) {
if (!this.tileMatrixSets) {
return;
}
return this.tileMatrixSets[tmsID];
},
getTerritories: function () {
return this.territories;
},
getTerritoryConf: function (territoryID) {
if (!this.territories) {
return;
}
return this.territories[territoryID];
},
getServices: function () {
return this.services;
},
getServiceConf: function (serviceID) {
if (!this.services) {
return;
}
return this.services[serviceID];
}
};
Expand Down Expand Up @@ -2487,6 +2501,9 @@ ServicesAutoConfResponseModelLayer = function () {
return this.styles;
},
getDefaultStyle: function () {
if (!this.styles) {
return;
}
var style;
var s = this.styles;
for (var i = 0; i < s.length; i++) {
Expand All @@ -2501,6 +2518,9 @@ ServicesAutoConfResponseModelLayer = function () {
return this.thematics;
},
getDefaultFormat: function () {
if (!this.formats) {
return;
}
var format;
var f = this.formats;
for (var i = 0; i < f.length; i++) {
Expand Down Expand Up @@ -4936,6 +4956,23 @@ ServicesGeocodeGeocode = function (Logger, _, ErrorService, CommonService, Direc
var filter = Object.keys(options.filterOptions);
for (var i = 0; i < filter.length; i++) {
var key = filter[i];
var filtersCouldBeNumberList = [
'department',
'number',
'postalCode',
'insee',
'importance',
'ID',
'IDTR',
'absorbedCity',
'sheet',
'section',
'inseeRegion',
'inseeDepartment'
];
if (filtersCouldBeNumberList.indexOf(key) !== -1 && typeof options.filterOptions[key] !== 'string') {
options.filterOptions[key] = options.filterOptions[key].toString();
}
if (!options.filterOptions[key] || Object.keys(options.filterOptions[key]).length === 0) {
delete this.options.filterOptions[key];
}
Expand Down Expand Up @@ -5324,6 +5361,24 @@ ServicesGeocodeResponseReverseGeocodeResponseFactory = function (Logger, MRes, E
}));
return;
}
if (options.scope && options.scope.options && options.scope.options.srs && options.scope.options.srs !== 'EPSG:4326') {
var location;
var pos;
if (data || data.locations || data.locations.length) {
for (var i = 0; i < data.locations.length; i++) {
location = data.locations[i];
if (location) {
pos = location.position;
if (pos) {
location.position = {
x: pos.y,
y: pos.x
};
}
}
}
}
}
}
} else {
options.onError.call(options.scope, new ErrorService({
Expand Down Expand Up @@ -5375,8 +5430,8 @@ ServicesGeocodeReverseGeocode = function (Logger, _, ErrorService, CommonService
}
this.options.maximumResponses = options.maximumResponses || 25;
this.options.returnFreeForm = options.returnFreeForm || false;
this.options.srs = options.srs || 'EPSG:4326';
if (ReverseGeocode.geoEPSG.indexOf(this.options.srs) !== -1) {
this.options.srs = options.srs || 'CRS:84';
if (ReverseGeocode.geoEPSG.indexOf(this.options.srs) === -1) {
this.options.position = {
x: this.options.position.y,
y: this.options.position.x
Expand Down Expand Up @@ -5410,7 +5465,7 @@ ServicesGeocodeReverseGeocode = function (Logger, _, ErrorService, CommonService
position: this.options.position,
returnFreeForm: this.options.returnFreeForm,
filterOptions: this.options.filterOptions,
srs: this.options.srs,
srs: 'EPSG:4326',
maximumResponses: this.options.maximumResponses
};
this.request = ReverseGeocodeRequestFactory.build(options);
Expand Down Expand Up @@ -7207,7 +7262,7 @@ Gp = function (XHR, Services, AltiResponse, Elevation, AutoCompleteResponse, Sug
var scope = typeof window !== 'undefined' ? window : {};
var Gp = scope.Gp || {
servicesVersion: '1.0.0-beta2',
servicesDate: '2016-05-18',
servicesDate: '2016-05-27',
extend: function (strNS, value) {
var parts = strNS.split('.');
var parent = this;
Expand Down
10 changes: 5 additions & 5 deletions dist/GpServices.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions samples/Services/Geocode/amd-xhr.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
onSuccess : function (response) {console.log(response.locations);},
onFailure : function (error) {console.log(error);},
// spécifique au service
location: "2 avenue de paris, 94166 Saint-Mandée",
// location: "2 avenue de paris, 94166 Saint-Mandée",
location: "brie",
returnFreeForm : false,
filterOptions :{
type : ["StreetAddress"]
type : ["StreetAddress"],
department : 77
},
maximumResponses : 25,
srs : 'EPSG:4326'
Expand Down
21 changes: 13 additions & 8 deletions samples/Services/ReverseGeocode/amd-xhr.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@
httpMethod : 'POST', // GET|POST
onSuccess : function (response) {console.log(response);},
onFailure : function (error) {console.log(error);},
// spécifique au service
position: {
x : 2,
y : 48
},
filterOptions :{
type : ['PositionOfInterest']
}
// spécifique au service
// position: {
// x : 2,
// y : 48
// },
position: {
x : 48,
y : 2
},
srs : "EPSG:4326",
filterOptions :{
type : ['PositionOfInterest']
}
};

var obj = new ReverseGeocode(options);
Expand Down
40 changes: 27 additions & 13 deletions src/Services/AutoConf/Response/model/AutoConfResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define([], function () {
* Response object for {@link module:Services~getConfig Gp.Services.getConfig()} invocation when successful. Received as the argument of onSuccess callback function.
*
* @property {Object} generalOptions - General properties for default map configuration resources.
* @property {Object} generalOptions.apiKeys - Object that associates apiKey(s) with an array of resources IDs availables with that key.
* @property {Object} generalOptions.apiKeys - Object that associates apiKey(s) with an array of resources IDs availables with that key.
* @property {String} generalOptions.title - Underlying web service Title.
* @property {String} generalOptions.defaultGMLGFIStyle - XSL URL used by default to translate an XML GetFeatureInfo response into an HTML array.
* @property {String} generalOptions.theme - default theme (FIXME : for what ?)
Expand All @@ -34,14 +34,14 @@ define([], function () {
wgs84Resolutions : []
};

this.layers = {};
this.layers = {};

this.territories = {};

this.tileMatrixSets = {};

this.services = {};

}

AutoConfResponse.prototype = {
Expand Down Expand Up @@ -88,9 +88,11 @@ define([], function () {
getLayersConf : function (apiKey) {
var layers = {};
var layersIdArray = this.getLayersId(apiKey);
for ( var i = 0; i < layersIdArray.length; i++ ) {
var lyrId = layersIdArray[i];
layers[lyrId] = this.layers[lyrId];
if ( layersIdArray ) {
for ( var i = 0; i < layersIdArray.length; i++ ) {
var lyrId = layersIdArray[i];
layers[lyrId] = this.layers[lyrId];
}
}
return layers;
},
Expand All @@ -102,13 +104,16 @@ define([], function () {
* @return {Object} layer - Layer configuration : instance of {@link Gp.Services.Config.Layer}
*/
getLayerConf : function (layerId) {
if ( !this.layers ) {
return;
}
return this.layers[layerId];
},

/**
* Returns an associative array of Tile Matrix Sets configurations.
*
* @return {Object} tileMatrixSets - Object which properties are TMS identifiers,
* @return {Object} tileMatrixSets - Object which properties are TMS identifiers,
* and corresponding values are instances of {@link Gp.Services.Config.TileMatrixSet}.
*/
getTileMatrixSets : function () {
Expand All @@ -119,16 +124,19 @@ define([], function () {
* Returns a Tile Matrix Sets configuration, given its identifier.
*
* @param {String} tmsID - Tile Matrix Set identifier (e.g. : "PM")
* @return {Object} tileMatrixSet - Tile Matrix Set configuration, instance of {@link Gp.Services.Config.TileMatrixSet}
* @return {Object} tileMatrixSet - Tile Matrix Set configuration, instance of {@link Gp.Services.Config.TileMatrixSet}
*/
getTMSConf : function (tmsID) {
if ( !this.tileMatrixSets ) {
return;
}
return this.tileMatrixSets[tmsID];
},

/**
* Returns an associative array of territories configurations.
*
* @return {Object} territories - Object which properties are territory identifiers,
* @return {Object} territories - Object which properties are territory identifiers,
* and corresponding values are instances of {@link Gp.Services.Config.Territory}.
*/
getTerritories : function () {
Expand All @@ -142,13 +150,16 @@ define([], function () {
* @return {Object} territory - Territory configuration, instance of {@link Gp.Services.Config.Territory}
*/
getTerritoryConf : function (territoryID) {
if ( !this.territories ) {
return;
}
return this.territories[territoryID];
},

/**
* Returns an associative array of services configurations.
*
* @return {Object} services - Object which properties are services identifiers,
* @return {Object} services - Object which properties are services identifiers,
* and corresponding values are instances of {@link Gp.Services.Config.Service}.
*/
getServices : function () {
Expand All @@ -159,13 +170,16 @@ define([], function () {
* Returns a service configuration, given its identifier.
*
* @param {String} serviceID - service identifier (e.g. "OGC:WMTS")
* @return {Object} service - service configuration, instance of {@link Gp.Services.Config.Service}
* @return {Object} service - service configuration, instance of {@link Gp.Services.Config.Service}
*/
getServiceConf : function (serviceID) {
if ( !this.services ) {
return;
}
return this.services[serviceID];
}

};

return AutoConfResponse;
});
Loading

0 comments on commit 10b3654

Please sign in to comment.