From da20621375d92f895c242f6fd6b2cbc65e98d15d Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 28 Sep 2018 12:59:38 +0200 Subject: [PATCH] API skeleton --- api/Map.js | 207 +++++++++++++++++++++++++++++++++ api/constants.js | 16 +++ api/dist/apihelp.html | 207 +++++++++++++++++++++++++++++++++ api/dist/data.txt | 6 + api/dist/github.css | 88 ++++++++++++++ api/dist/img/essence.png | Bin 0 -> 3761 bytes api/dist/img/info.png | Bin 0 -> 341 bytes api/dist/img/parking.png | Bin 0 -> 1115 bytes api/dist/rainbow-custom.min.js | 11 ++ api/index.js | 7 ++ buildtools/webpack.api.js | 16 +++ package.json | 3 + 12 files changed, 561 insertions(+) create mode 100644 api/Map.js create mode 100644 api/constants.js create mode 100644 api/dist/apihelp.html create mode 100644 api/dist/data.txt create mode 100644 api/dist/github.css create mode 100644 api/dist/img/essence.png create mode 100644 api/dist/img/info.png create mode 100644 api/dist/img/parking.png create mode 100644 api/dist/rainbow-custom.min.js create mode 100644 api/index.js create mode 100644 buildtools/webpack.api.js diff --git a/api/Map.js b/api/Map.js new file mode 100644 index 000000000000..87335502203d --- /dev/null +++ b/api/Map.js @@ -0,0 +1,207 @@ +// see https://github.com/camptocamp/cgxp/blob/master/core/src/script/CGXP/api/Map.js + +import OLMap from 'ol/Map.js'; +import Feature from 'ol/Feature.js'; +import Point from 'ol/geom/Point.js'; +import {Icon, Style} from 'ol/style.js'; +import View from 'ol/View.js'; +import VectorSource from 'ol/source/Vector.js'; +import VectorLayer from 'ol/layer/Vector.js'; +import TileLayer from 'ol/layer/Tile.js'; + +import {get as getProjection} from 'ol/proj.js'; + +import * as constants from './constants.js'; + +// FIXME: temporary +import SwisstopoSource from '@geoblocks/sources/Swisstopo.js'; +import EPSG21781 from '@geoblocks/sources/EPSG21781.js'; + + +class Map { + + /** + * @param {Object} options + * @property {string} div + * @property {ol.Coordinate} center + * @property {number} [zoom=10] + * TODO: more options + */ + constructor(options) { + /** + * @private + * @type {View} + */ + this.view_ = new View({ + projection: getProjection(constants.projection || 'EPSG:21781'), + resolutions: constants.resolutions, + zoom: options.zoom !== undefined ? options.zoom : 10, + center: options.center + }); + + /** + * @private + * @type {OLMap} + */ + this.map_ = new OLMap({ + controls: [], + target: options.div, + view: this.view_ + }); + + // FIXME: temporary + const background = new TileLayer({ + source: new SwisstopoSource({ + layer: 'ch.swisstopo.pixelkarte-farbe', + format: 'image/jpeg', + timestamp: 'current', + projection: EPSG21781, + crossOrigin: 'anonymous' + }) + }); + this.map_.addLayer(background); + + /** + * @private + * @type {VectorSource} + */ + this.vectorSource_ = new VectorSource(); + + /** + * @private + * @type {VectorLayer} + */ + this.vectorLayer_ = new VectorLayer({ + source: this.vectorSource_ + }); + + this.map_.addLayer(this.vectorLayer_); + } + + /** + * @param {ol.Coordinate} center + * @param {number} zoom + */ + recenter(center, zoom) { + this.view_.setCenter(center); + this.view_.setZoom(zoom); + } + + /** + * @param {Object} options + * @property {ol.Coordinate} position + * @property {string} [icon] + * @property {ol.Size} [size] + */ + addMarker(options = {}) { + const marker = new Feature({ + geometry: new Point(options.position ? options.position : this.view_.getCenter()) + }); + if (options.icon) { + // FIXME: use size? + marker.setStyle(new Style({ + image: new Icon({ + src: options.icon + }) + })); + } + this.vectorSource_.addFeature(marker); + } + + /** + * @param {string} layer + * @param {Array.} ids + * @param {boolean} [highlight=false] + */ + recenterOnObjects(layer, ids, highlight = false) { + + } + + /** + * @param {string} type Layer type, only 'text' format is supported. + * @param {string} name + * @param {string} url + * @param {Object} [options] + * @property {Array.} [attr=['title', 'description']] + * @property {function()} [success] + * @property {function()} [error] + */ + addCustomLayer(type, name, url, options = {}) { + fetch(url) + .then((response) => response.text()) + .then((text) => { + const attr = options.attr || ['title', 'description']; + const lines = text.split(/\r\n|\r|\n/); + const columns = lines.shift().split('\t'); + for (const line of lines) { + if (line) { + const values = zip(columns, line.split('\t')); + const marker = new Feature({ + geometry: new Point(values.point.split(',').map(parseFloat)) + }); + marker.setProperties(filterByKeys(values, attr)); + marker.setId(values.id); + // FIXME: handle values.iconSize + // FIXME: handle values.iconOffset + marker.setStyle(new Style({ + image: new Icon({ + src: values.icon + }) + })); + this.vectorSource_.addFeature(marker); + } + } + this.view_.fit(this.vectorSource_.getExtent()); + }) + .then(() => { + if (options.success) { + options.success(); + } + }) + .catch(() => { + if (options.error) { + options.error(); + } + }); + } + + /** + * @param {string} id + */ + selectObject(id) { + const feature = this.vectorSource_.getFeatureById(id); + if (feature) { + // TODO + } + } + +} + + +/** + * @param {Array.} keys + * @param {Array.<*>} values + */ +function zip(keys, values) { + const obj = {}; + keys.forEach((key, index) => { + obj[key] = values[index]; + }); + return obj; +} + + +/** + * @param {Object.} obj + * @param {Array.} keys + */ +function filterByKeys(obj, keys) { + const filtered = {}; + keys.forEach((key) => { + filtered[key] = obj[key]; + }); + return filtered; +} + + +export default Map; diff --git a/api/constants.js b/api/constants.js new file mode 100644 index 000000000000..e44a8291ed36 --- /dev/null +++ b/api/constants.js @@ -0,0 +1,16 @@ +/** + * @type {string} + */ +export const projection = 'EPSG:21781'; + + +/** + * @type {Array.} + */ +export const resolutions = [250, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.25, 0.1, 0.05]; + + +/** + * @type {string} + */ +export const backgroundLayer = 'plan'; diff --git a/api/dist/apihelp.html b/api/dist/apihelp.html new file mode 100644 index 000000000000..f4802e42c6b6 --- /dev/null +++ b/api/dist/apihelp.html @@ -0,0 +1,207 @@ + + + + + API description + + + + + + +
+

Simple API Help

+

+This page describes how to use the Simple API. The Simple API +provides a JavaScript API for inserting simple maps into web pages. +

+

Basis

+

To use the API you should add the following HTML:

+
<script src="https://geomapfish-demo.camptocamp.com/2.4/wsgi/api.js"></script>
+<script>
+window.onload = function() {
+    // add the code here
+};
+</script>
+

To put a new map in the page you'll have to put a div element with a +certain id where you want your map to be: +

<div id='map1' style='width:700px;height:400px;'></div>
+ +
+

A map

+
+
var map = new demo.Map({
+    div: 'map1', // id of the div element to put the map in
+    zoom: 8,
+    center: [544500, 210100]
+});
+
+ +
+

A map with a marker on its center

+
+
var map = new demo.Map({
+    div: 'map2',
+    zoom: 8,
+    center: [544500, 210100]
+});
+map.addMarker();
+
+ +
+

A map with several custom markers

+
+
var map = new demo.Map({
+    div: 'map3',
+    zoom: 8,
+    center: [544500, 210100]
+});
+map.addMarker({
+    position: [544410, 210100],
+    size: [14, 14],
+    icon: 'img/info.png'
+});
+map.addMarker({
+    position: [544450, 210000],
+    size: [18, 18],
+    icon: 'img/essence.png'
+});
+map.addMarker({
+    position: [544310, 210200],
+    size: [14, 14],
+    icon: 'img/parking.png'
+});
+
+ +
+

A map with a subset of overlays

+
+
var map = new demo.Map({
+    div: 'map4',
+    zoom: 8,
+    center: [544500, 210100],
+    layers: ['parcelles', 'batiments_ofs']
+});
+
+ +
+

A map with some additional controls

+
+
var map = new demo.Map({
+    div: 'map5',
+    zoom: 8,
+    center: [544500, 210100],
+    layers: ['mo4_pfp_3'],
+    addLayerSwitcher: true,
+    layerSwitcherExpanded: true,
+    addMiniMap: true,
+    miniMapExpanded: true,
+    showCoords: true
+});
+
+
+ +
+

Recenter the map to given coordinates

+ + +
+
+
var map_ = new demo.Map({
+    div: 'map6',
+    addMiniMap: true,
+    miniMapExpanded: true
+});
+var button1 = document.getElementById('button1');
+button1.onclick = function() {
+    map_.recenter([543500, 202154], 7);
+}
+var button2 = document.getElementById('button2');
+button2.onclick = function() {
+    map_.recenter([564500, 216100], 9);
+}
+
+
+ +
+

Recenter the map on objects

+
+
var map = new demo.Map({
+    div: 'map7',
+    layers: ['batiments_ofs']
+});
+map.recenterOnObjects(
+    /* the layer name */
+    'batiments_ofs',
+    /* the ids of the objects */
+    ['1474234', '1474232'],
+    /* whether to highlight the objects or not */
+    true
+);
+
+
+ +
+

Load data from a text file

+ See data.txt. +
+
+
var map = new demo.Map({
+    div: 'map9'
+});
+map.addCustomLayer('text', 'My custom txt layer', 'data.txt', {
+  success: function() {
+    map.selectObject(2);
+  }
+});
+
+
+ +
+ + + diff --git a/api/dist/data.txt b/api/dist/data.txt new file mode 100644 index 000000000000..ad3ad25ef3a9 --- /dev/null +++ b/api/dist/data.txt @@ -0,0 +1,6 @@ +id point title description icon iconSize iconOffset +1 553000,216300 Information Office de l'information
Tél: 032 000 00 00
Email: info@example.com
Internet: Cliquer ici http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker.png 21,25 -10.5,-12.5 +2 554250,215600 Ma première station Diesel pas cher http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png 21,25 -10.5,-12.5 +3 552556,215864 Mon parking C'est celui-là le meilleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png 21,25 -10.5,-12.5 +4 554489,217126 Mon parking Ce parking est
le meillleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png 21,25 -10.5,-12.5 +5 554089,217326 Ma deuxième station Sans-plomb pas cher. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png 21,25 -10.5,-12.5 diff --git a/api/dist/github.css b/api/dist/github.css new file mode 100644 index 000000000000..088f065754c1 --- /dev/null +++ b/api/dist/github.css @@ -0,0 +1,88 @@ +/** + * GitHub theme + * + * @author Craig Campbell + * @version 1.0.4 + */ +pre { + border: 1px solid #ccc; + word-wrap: break-word; + padding: 6px 10px; + line-height: 19px; + margin-bottom: 20px; +} + +code { + border: 1px solid #eaeaea; + margin: 0px 2px; + padding: 0px 5px; + font-size: 12px; +} + +pre code { + border: 0px; + padding: 0px; + margin: 0px; + -moz-border-radius: 0px; + -webkit-border-radius: 0px; + border-radius: 0px; +} + +pre, code { + font-family: Consolas, 'Liberation Mono', Courier, monospace; + color: #333; + background: #f8f8f8; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} + +pre, pre code { + font-size: 13px; +} + +pre .comment { + color: #998; +} + +pre .support { + color: #0086B3; +} + +pre .tag, pre .tag-name { + color: navy; +} + +pre .keyword, pre .css-property, pre .vendor-prefix, pre .sass, pre .class, pre .id, pre .css-value, pre .entity.function, pre .storage.function { + font-weight: bold; +} + +pre .css-property, pre .css-value, pre .vendor-prefix, pre .support.namespace { + color: #333; +} + +pre .constant.numeric, pre .keyword.unit, pre .hex-color { + font-weight: normal; + color: #099; +} + +pre .entity.class { + color: #458; +} + +pre .entity.id, pre .entity.function { + color: #900; +} + +pre .attribute, pre .variable { + color: teal; +} + +pre .string, pre .support.value { + font-weight: normal; + color: #d14; +} + +pre .regexp { + color: #009926; +} diff --git a/api/dist/img/essence.png b/api/dist/img/essence.png new file mode 100644 index 0000000000000000000000000000000000000000..18877a8ac991b693ef594cc810760fda57a4441f GIT binary patch literal 3761 zcmV;i4o>ljP)Oz@Z0f2-7z;ux~O9+4z06=<WDR*FRcSTFz- zW=q650N5=6FiBTtNC2?60Km==3$g$R3;-}uh=nNt1bYBr$Ri_o0EC$U6h`t_Jn<{8 z5a%iY0C<_QJh>z}MS)ugEpZ1|S1ukX&Pf+56gFW3VVXcL!g-k)GJ!M?;PcD?0HBc- z5#WRK{dmp}uFlRjj{U%*%WZ25jX z{P*?XzTzZ-GF^d31o+^>%=Ap99M6&ogks$0k4OBs3;+Bb(;~!4V!2o<6ys46agIcq zjPo+3B8fthDa9qy|77CdEc*jK-!%ZRYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S z1Au6Q;m>#f??3%Vpd|o+W=WE9003S@Bra6Svp>fO002awfhw>;8}z{#EWidF!3EsG z3;bXU&9EIRU@z1_9W=mEXoiz;4lcq~xDGvV5BgyU zp1~-*fe8db$Osc*A=-!mVv1NJjtCc-h4>-CNCXm#Bp}I%6j35eku^v$Qi@a{RY)E3 zJ#qp$hg?Rwkvqr$GJ^buyhkyVfwECO)C{#lxu`c9ghrwZ&}4KmnvWKso6vH!8a<3Q zq36)6Xb;+tK10Vaz~~qUGsJ8#F2=(`u{bOVlVi)VBCHIn#u~6ztOL7=^<&SmcLWlF zMZgI*1b0FpVIDz9SWH+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An;IaamAvpduq00000NkvXXu0mjfxJeq` literal 0 HcmV?d00001 diff --git a/api/dist/img/info.png b/api/dist/img/info.png new file mode 100644 index 0000000000000000000000000000000000000000..7fc771ff0f9a7408bfb4ff52a46e0e625dac8745 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt-24T^vI+ z&L{u)|KFaOXMc9;gZkK$22Vpd4=XYECbI_q&98ZTEd8`{Hm$WlJsVjMY_q*8t|0cH?d*1){NU)FwiB^`_+v@ZG`2YGLuR&d$ zV8_Gs336-!Cl-1?DADqfThU(Adt;85hw_b;H<;MxyHz}xAS-)Ah#{=^1!uz|6?Z=+ ac7|^!uX3#}F?R?0j=|H_&t;ucLK6UI8-J7l literal 0 HcmV?d00001 diff --git a/api/dist/img/parking.png b/api/dist/img/parking.png new file mode 100644 index 0000000000000000000000000000000000000000..222e735defbced3e264dc1b896082e8dfbc16d04 GIT binary patch literal 1115 zcmV-h1f=_kP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS` z3J53k4k3g900Y}eL_t(Y$EB7{iyc)EhMzj;^u2v28SxquoR}yI>M9acPy;UfSSlDI zDCj>BbeFB<4+u(rfFeYMB!cc-io}41BoK(MG?+MXW|A4_PVU_9K2_zS@5e+;3`s#P zy6IE(R=xGsX<=-~Pn_%*QOXE7cW(|f&gjs=gR1}naO%|Q*B{xv>!amL7Ah4)?lQPT zH#!e?{puf!OGgg8_`Y=e z*B6#Jy;vh5Ovgi+O-h)QmCea&t-GV+a@;}98Pv+4RyJy-RwIcpUnbsrW`Ta8WZiP! zd`e~lFn1brnn{byQEwka;L_TNFD|Y!*GYsR>?i~8?%&0p{v06)FF$r4pI=y~NU;rS zj*S5Ze1=lhS~qJeke1HIV7U^OE8*%8&aY&Som-re`sB_zMs;)3dB?#axj2m(n~hUj zi&zj0pHPN7WL0Vv+@V%uSj$bb*|x?2C!1g{I8MUB)LC4wsTGPSBncFuK{XImsT*T? zZG&!+h(UO0TjJ2Zz0>$VUtVKnsLWf#ToLGn$hgBZ4&0n7J5>fJQ%a5Ih^X?!jvk-A z`6y+#OHm|xMPhqdv~-zq?A$Vq1y+ZdHF4@*!mNV>shxjEz3tsZMjB=kD`MdOUO~5; zNJWPf+c8}m)*Sue5|;*!1e<<8s4{hq;7&4g+ziWxjg{=Q!b4h~mj)F-{<_XwS>Qw( zbFK}QGgmhFbDyXFiX8qC_2&EFxT9ule}&^;uiSAc6=f#i?c{ zrq;&5o#bYiX*-%aYmtR5(g)OM+L$8s|K3y@17?PslT63usI}s7aA7KxiJWzdc>d2O zdccgN=7`!@XcG<`+d`T<<6U)U2`scpP$QWss*0*lTjW5FaHBC&t!y?nRr(!O5Cydi zo=K{TXQeTtHb=y9gez6z@b?1?!l&u*xF= z`0}gcZ|vRmz>(iJSlDQ|r%QiZfjqvQKQAv`Kl0AoZ+$Zj^~tA4`(+V&QSRxl1#@Jx h@y!oEcz+G>e*i~(s70i@Syuo6002ovPDHLkV1lBa0^=e[d][c])delete e[d][c],delete j[d][c];if(a>=c&&ac&&b'+b+""}function s(a,b,c,h){var f=a.exec(c);if(f){++t;!b.name&&"string"==typeof b.matches[0]&&(b.name=b.matches[0],delete b.matches[0]);var k=f[0],i=f.index,u=f[0].length+i,g=function(){function f(){s(a,b,c,h)}t%100>0?f():setTimeout(f,0)};if(C(i,u))g();else{var m=v(b.matches),l=function(a,c,h){if(a>=c.length)h(k);else{var d=f[c[a]];if(d){var e=b.matches[c[a]],i=e.language,g=e.name&&e.matches? +e.matches:e,j=function(b,d,e){var i;i=0;var g;for(g=1;g/g,">").replace(/&(?![\w\#]+;)/g, +"&"),b,c)}function o(a,b,c){if(b { + const library = argv.library ? argv.library : 'demo'; + return { + entry: './api/index.js', + output: { + filename: 'api.js', + path: path.resolve(__dirname, 'api/dist/'), + libraryTarget: 'umd', + globalObject: 'this', + libraryExport: 'default', + library: library + } + }; +}; diff --git a/package.json b/package.json index 0d9ec37a77ec..3be1b97a847f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "build-ngeo-examples": "TARGET=ngeo-examples webpack --progress --debug", "build-gmf-examples": "TARGET=gmf-examples webpack --progress --debug", "build-gmf-apps": "TARGET=gmf-apps webpack --progress --debug", + "build-api": "webpack --config buildtools/webpack.api.js --mode development --library demo", + "serve-api": "webpack-dev-server --mode development --content-base api/dist/ --config buildtools/webpack.api.js --port 3000 --progress --watch --bail --debug", "serve-ngeo-examples": "DEV_SERVER=1 TARGET=ngeo-examples webpack-dev-server --port 3000 --progress --watch --bail --debug", "serve-gmf-examples": "DEV_SERVER=1 TARGET=gmf-examples webpack-dev-server --port 3000 --progress --watch --bail --debug", "serve-gmf-apps": "DEV_SERVER=1 TARGET=gmf-apps webpack-dev-server --port 3000 --progress --watch --bail --debug" @@ -22,6 +24,7 @@ "compile-catalog": "buildtools/compile-catalog.js" }, "devDependencies": { + "@geoblocks/sources": "https://api.github.com/repos/geoblocks/sources/tarball/173ad0171", "@babel/core": "7.1.2", "@babel/plugin-syntax-object-rest-spread": "7.0.0", "@babel/plugin-transform-spread": "7.0.0",