Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | 6x 6x 6x 6x 6x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 7x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 4x 1x 1x 2x 6x 6x 6x 6x | import Logger from "../../../../Utils/LoggerByDefault"; /** * @classdesc * Location de type Position * * ``` * XSD * Position (balise xsd) : * ex. <Position><gml:Point xmlns:gml="http://www.opengis.net/gml"><gml:pos>50.347775 3.205098</gml:pos></gml:Point></Position> * ex. <Position><gml:CircleByCenterPoint xmlns:gml="http://www.opengis.net/gml"><gml:pos>48.85978570614691 2.2913572761128878</gml:pos><gml:radius>1000</gml:radius></gml:CircleByCenterPoint></Position> * (au choix) * element ref="gml:Point" * element ref="gml:CircleByCenterPoint" * element ref="gml:Polygon" * element ref="gml:MultiPolygon" * ``` * * FIXME les autres elements ne sont pas implémentés (QoP, Speed, Direction, Time, ...) ? * * ``` * template : "<Position> * __GMLPOINT__ * __GMLFILTER__ * </Position>" * ``` * ``` * GML : { * pos : "<gml:pos>__X__ __Y__</gml:pos>", * point : "<gml:Point xmlns:gml=\"http://www.opengis.net/gml\">__POS__</gml:Point>", * circle : "<gml:CircleByCenterPoint xmlns:gml=\"http://www.opengis.net/gml\">__POS__<gml:radius>__RADIUS__</gml:radius></gml:CircleByCenterPoint>", * // not yet implemented ! * polygon : "", * multipolygon : "" * } * ``` * * @constructor * @alias Gp.Formats.XLS.LocationUtilityService.Position * @param {Object} options - options données en entrée * @param {Object} options.position - x/y * @param {Object} options.filter - filtre * @param {Object} options.filter.circle - un cercle * @param {Object} options.filter.polygon - un polygone * * @private */ function Position (options) { this.logger = Logger.getLogger("Position"); this.logger.trace("[Constructeur Position ()]"); Iif (!(this instanceof Position)) { throw new TypeError("Position constructor cannot be called as a function."); } // param par defaut this.options = options || {}; // param obligatoire Iif (!this.options.position) { throw new Error("l'option 'position' n'est pas renseignée !"); } } /** * @lends module:Position# */ Position.prototype = { /** * Constructeur (alias) */ constructor : Position, /** * request (out) * @type {String} */ requestString : null, /** * Template de la requête. * * substitution des valeurs suivantes : * __GMLPOINT__ __GMLFILTER__ * __X__ __Y__ __RADIUS__ * __XY__ * @todo indentation XML * @todo implementation classe GML */ template : { position : "<Position>" + "__GMLPOINT__" + "__GMLFILTER__" + "</Position>", gml : { point : "<gml:Point xmlns:gml=\"http://www.opengis.net/gml\"><gml:pos>__X__ __Y__</gml:pos></gml:Point>", pos : null, filter : { bbox : "<gml:Envelope xmlns:gml=\"http://www.opengis.net/gml\">" + "<gml:lowerCorner>__LEFT__ __BOTTOM__</gml:lowerCorner>" + "<gml:upperCorner>__RIGHT__ __TOP__</gml:upperCorner>" + "</gml:Envelope>", circle : "<gml:CircleByCenterPoint xmlns:gml=\"http://www.opengis.net/gml\"><gml:pos>__X__ __Y__</gml:pos><gml:radius>__RADIUS__</gml:radius></gml:CircleByCenterPoint>", polygon : "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\"><gml:exterior><gml:LinearRing><gml:posList>__XY__</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>", multipolygon : null } } } }; /** * toString * * @returns {String} requête */ Position.prototype.toString = function () { var template = this.template.position; var tmplGmlPoint = this.template.gml.point; tmplGmlPoint = tmplGmlPoint.replace(/__X__/g, this.options.position.x); tmplGmlPoint = tmplGmlPoint.replace(/__Y__/g, this.options.position.y); var tmplGmlFilter = ""; Eif (this.options.filter) { var filter = this.options.filter; for (var name in filter) { switch (name) { case "circle": tmplGmlFilter = this.template.gml.filter[name]; tmplGmlFilter = tmplGmlFilter.replace(/__X__/g, filter[name].x); tmplGmlFilter = tmplGmlFilter.replace(/__Y__/g, filter[name].y); tmplGmlFilter = tmplGmlFilter.replace(/__RADIUS__/g, filter[name].radius); break; case "bbox": tmplGmlFilter = this.template.gml.filter[name]; tmplGmlFilter = tmplGmlFilter.replace(/__LEFT__/g, filter[name].left); tmplGmlFilter = tmplGmlFilter.replace(/__BOTTOM__/g, filter[name].bottom); tmplGmlFilter = tmplGmlFilter.replace(/__RIGHT__/g, filter[name].right); tmplGmlFilter = tmplGmlFilter.replace(/__TOP__/g, filter[name].top); break; case "polygon": // FIXME implementation simple du polygone ! // aucun test de fermeture du polygone, ni de gestion des trous ! tmplGmlFilter = this.template.gml.filter[name]; var strPoints = ""; var lstPoints = filter[name]; for (var i = 0; i < lstPoints.length; i++) { var coord = lstPoints[i]; Iif (Array.isArray(coord)) { this.logger.error("Holes are not implemented !"); break; } Eif ((coord.x && coord.y) || (coord.x === 0 || coord.y === 0)) { strPoints += coord.x + " " + coord.y; } if (lstPoints.length !== i + 1) { strPoints += " "; } } tmplGmlFilter = tmplGmlFilter.replace(/__XY__/g, strPoints); break; case "multipolygon": this.logger.warn("Filter '" + name + "' is not yet implemented !"); break; default: this.logger.error("This filter '" + name + "' is not useful !"); } } } template = template.replace(/__GMLPOINT__/g, tmplGmlPoint); template = template.replace(/__GMLFILTER__/g, tmplGmlFilter); this.requestString = template; return this.requestString; }; export default Position; |