Commit bba03705 authored by Vincent Dubois's avatar Vincent Dubois

Correction request osm elements multiple id

parent b28302b2
/// <reference path="typings/tsd.d.ts" />
/// <reference path="myTypings/tsd.d.ts" />
declare function osmtogeojson(any): GeoJSONGeoJsonObject
declare function osmtogeojson(any): any
/**
*
......@@ -394,8 +394,13 @@ class Geocropping {
});
let elementChanged = () => {
// TODO: mettre a jour le style et les donnée
//mettre a jour le style et les donnée
let req = OauthOsm.apiRequest.GetElementId;
req.params.id = properties.id
req.params.type = properties.type
this._searchInfoElementsOSM().then(data => {
this._updateElementsDisplayed(data);
});
popupEvent.target.closePopup();
}
......@@ -778,6 +783,7 @@ class Geocropping {
}
}
// juste les position des elements avec overpass api
_searchDataAround(pos: L.LatLng) {
if (!(pos instanceof L.LatLng))
return;
......@@ -834,6 +840,11 @@ class Geocropping {
}
});
// récupérer les information des Point affiché directement sur osm (ne pas avoir le problème de cache des serveur interprete)
this._searchInfoElementsOSM().then(data => {
this._updateElementsDisplayed(data);
});
///////////////////////
//fixer sur les élément trouvés
//this._map.setMaxBounds(this._geoJSONLayers.getBounds());
......@@ -898,4 +909,69 @@ class Geocropping {
}
});
}
_searchInfoElementsOSM() {
let ids = [];
for (var key in this._featureDisplayed) {
if (this._featureDisplayed.hasOwnProperty(key)) {
let regexp = key.match(/^node\/(\d+)/);
if (regexp && regexp[1]) {
ids.push(regexp[1]);
}
}
}
let req = OauthOsm.apiRequest.GetElementsId;
req.params.type = "nodes";
req.params.ids = ids;
return this._osm._sendRequest(req);
}
_updateElementsDisplayed(data: { any?}) {
let type;
let obj = [];
for (var key in data) {
if (data.hasOwnProperty(key) && key !== "@attributes") {
type = key;
obj = data[type];
}
}
if (!(obj instanceof Array) && obj instanceof Object) {
obj = [obj];
}
for (let index = 0; index < obj.length; index++) {
let element = obj[index];
let feature = this._featureDisplayed[`${type}/${element["@attributes"].id}`]
if (feature && element["@attributes"]) {
if (element["@attributes"].visible) {
delete element["@attributes"].visible;
}
let osm = {
type: type
};
for (let key in element["@attributes"]) {
if (element["@attributes"].hasOwnProperty(key)) {
let attribute = element["@attributes"][key];
if ((Number as any).isInteger(attribute)) {
attribute = Number(attribute);
}
osm[key] = attribute;
}
}
let tags = element['tag'];
if (tags) {
osm['tags'] = {};
if (!(tags instanceof Array) && tags instanceof Object) {
tags = [tags];
}
for (let i = 0; i < tags.length; i++) {
let tag = tags[i];
osm['tags'][tag["@attributes"].k] = tag["@attributes"].v;
}
}
feature.layer.feature = osmtogeojson({ elements: [osm] }).features[0];
this._geoJSONLayers.resetStyle(feature.layer);
}
}
}
}
......@@ -170,8 +170,8 @@ class OauthOsm {
url: '/',
request: 'GetElementsId',
params: {
id: [100, 102],
type: 'node' // [node|way|relation]
ids: [100, 102],
type: 'nodes' // [node|way|relation]
}
},
GetElementIdRelations: {
......
/// <reference path="tsd.d.ts" />
/// <reference path="../myTypings/tsd.d.ts" />
/// <reference types="geojson" />
/// <reference types="leaflet" />
/// <reference types="jquery" />
declare function osmtogeojson(any: any): GeoJSONGeoJsonObject;
declare function osmtogeojson(any: any): any;
/**
*
*
......@@ -63,4 +62,8 @@ declare class Geocropping {
_locationFound(data: L.LocationEvent, options?: any): void;
_locationError(options: any, data: any): void;
_searchDataAround(pos: L.LatLng): void;
_searchInfoElementsOSM(): JQueryPromise<{}>;
_updateElementsDisplayed(data: {
any?;
}): void;
}
......@@ -145,7 +145,7 @@ declare class OauthOsm {
url: string;
request: string;
params: {
id: number[];
ids: number[];
type: string;
};
};
......
This diff is collapsed.
......@@ -298,7 +298,13 @@ var Geocropping = (function () {
$valid.prop('disabled', !disabled);
});
var elementChanged = function () {
// TODO: mettre a jour le style et les donnée
//mettre a jour le style et les donnée
var req = OauthOsm.apiRequest.GetElementId;
req.params.id = properties.id;
req.params.type = properties.type;
_this._searchInfoElementsOSM().then(function (data) {
_this._updateElementsDisplayed(data);
});
popupEvent.target.closePopup();
};
var $errorForm = $("#" + properties.id + "Signal form", popupEvent.popup.getElement());
......@@ -661,6 +667,7 @@ var Geocropping = (function () {
this.stopLocateUser();
}
};
// juste les position des elements avec overpass api
Geocropping.prototype._searchDataAround = function (pos) {
var _this = this;
if (!(pos instanceof L.LatLng))
......@@ -714,6 +721,10 @@ var Geocropping = (function () {
_this._featureDisplayed[layer.feature.id] = { layer: layer };
}
});
// récupérer les information des Point affiché directement sur osm (ne pas avoir le problème de cache des serveur interprete)
_this._searchInfoElementsOSM().then(function (data) {
_this._updateElementsDisplayed(data);
});
///////////////////////
//fixer sur les élément trouvés
//this._map.setMaxBounds(this._geoJSONLayers.getBounds());
......@@ -773,6 +784,68 @@ var Geocropping = (function () {
}
});
};
Geocropping.prototype._searchInfoElementsOSM = function () {
var ids = [];
for (var key in this._featureDisplayed) {
if (this._featureDisplayed.hasOwnProperty(key)) {
var regexp = key.match(/^node\/(\d+)/);
if (regexp && regexp[1]) {
ids.push(regexp[1]);
}
}
}
var req = OauthOsm.apiRequest.GetElementsId;
req.params.type = "nodes";
req.params.ids = ids;
return this._osm._sendRequest(req);
};
Geocropping.prototype._updateElementsDisplayed = function (data) {
var type;
var obj = [];
for (var key in data) {
if (data.hasOwnProperty(key) && key !== "@attributes") {
type = key;
obj = data[type];
}
}
if (!(obj instanceof Array) && obj instanceof Object) {
obj = [obj];
}
for (var index = 0; index < obj.length; index++) {
var element = obj[index];
var feature = this._featureDisplayed[type + "/" + element["@attributes"].id];
if (feature && element["@attributes"]) {
if (element["@attributes"].visible) {
delete element["@attributes"].visible;
}
var osm = {
type: type
};
for (var key_1 in element["@attributes"]) {
if (element["@attributes"].hasOwnProperty(key_1)) {
var attribute = element["@attributes"][key_1];
if (Number.isInteger(attribute)) {
attribute = Number(attribute);
}
osm[key_1] = attribute;
}
}
var tags = element['tag'];
if (tags) {
osm['tags'] = {};
if (!(tags instanceof Array) && tags instanceof Object) {
tags = [tags];
}
for (var i = 0; i < tags.length; i++) {
var tag = tags[i];
osm['tags'][tag["@attributes"].k] = tag["@attributes"].v;
}
}
feature.layer.feature = osmtogeojson({ elements: [osm] }).features[0];
this._geoJSONLayers.resetStyle(feature.layer);
}
}
};
return Geocropping;
}());
//# sourceMappingURL=Geocropping.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -162,8 +162,8 @@ var OauthOsm = (function () {
url: '/',
request: 'GetElementsId',
params: {
id: [100, 102],
type: 'node' // [node|way|relation]
ids: [100, 102],
type: 'nodes' // [node|way|relation]
}
},
GetElementIdRelations: {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment