Hi,

I want to use geojson-vt in GNOME Maps.
The project can be found at https://github.com/mapbox/geojson-vt

The reason I want it is because it solves showing big sets of GeoJSON
data without being slow. It does this with tricks:
https://www.mapbox.com/blog/introducing-geojson-vt/

I have mangaged to get this working in Maps, it required me to change
how the including of modules was done. Since geojson-vt uses Node.js style
includes with require and module.export. The patch needed to get geojson-vt
included is attached to this mail.

The license for geojson-vt can be found here:
https://github.com/mapbox/geojson-vt/blob/master/LICENSE

So how do I do this best? Do we need a best practice? Has this been done before?
I wanted to discuss it here since I or someone else might want to use
other javascript code from Github or other places.

I was thinking of having an import/geojson-vt branch were I keep the
code unpatched and use that if I want to get updates from geojson-vt.
And then apply my changes on a differant branch, like master.

Should I checking everything from the geojson-vt repo? Should I use a
git submodule? Should I abandon this idea totally and write
my own geojson code?

Thankful for replies
From 0baca43e76433a58933de9051ebc83e3c2fe19f9 Mon Sep 17 00:00:00 2001
From: Jonas Danielsson <[email protected]>
Date: Thu, 22 Oct 2015 14:35:01 +0200
Subject: [PATCH] geojson-vt: Update to GJS style import

---
 src/clip.js      |  2 --
 src/convert.js   |  4 +---
 src/index.js     | 14 ++++++--------
 src/simplify.js  |  2 --
 src/tile.js      |  2 --
 src/transform.js |  3 ---
 src/wrap.js      |  4 +---
 7 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/src/clip.js b/src/clip.js
index f657ad8..cad7a21 100644
--- a/src/clip.js
+++ b/src/clip.js
@@ -1,7 +1,5 @@
 'use strict';
 
-module.exports = clip;
-
 /* clip features between two axis-parallel lines:
  *     |        |
  *  ___|___     |     /
diff --git a/src/convert.js b/src/convert.js
index 920498e..669473a 100644
--- a/src/convert.js
+++ b/src/convert.js
@@ -1,8 +1,6 @@
 'use strict';
 
-module.exports = convert;
-
-var simplify = require('./simplify');
+const simplify = imports.simplify.simplify;
 
 // converts GeoJSON feature into an intermediate projected JSON vector format with simplification data
 
diff --git a/src/index.js b/src/index.js
index 4cf532e..c2c3626 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,13 +1,11 @@
 'use strict';
 
-module.exports = geojsonvt;
-
-var convert = require('./convert'),     // GeoJSON conversion and preprocessing
-    transform = require('./transform'), // coordinate transformation
-    clip = require('./clip'),           // stripe clipping algorithm
-    wrap = require('./wrap'),           // date line processing
-    createTile = require('./tile');     // final simplified tile generation
-
+const convert = imports.convert.convert;
+const transform = { tile: imports.transform.transformTile,
+                    point: imports.transform.transformPoint };
+const clip = imports.clip.clip;
+const createTile = imports.tile.createTile;
+const wrap = imports.wrap.wrap;
 
 function geojsonvt(data, options) {
     return new GeoJSONVT(data, options);
diff --git a/src/simplify.js b/src/simplify.js
index fe9eea6..2e55972 100644
--- a/src/simplify.js
+++ b/src/simplify.js
@@ -1,7 +1,5 @@
 'use strict';
 
-module.exports = simplify;
-
 // calculate simplification data using optimized Douglas-Peucker algorithm
 
 function simplify(points, tolerance) {
diff --git a/src/tile.js b/src/tile.js
index 4e6ccb1..764d538 100644
--- a/src/tile.js
+++ b/src/tile.js
@@ -1,7 +1,5 @@
 'use strict';
 
-module.exports = createTile;
-
 function createTile(features, z2, tx, ty, tolerance, noSimplify) {
     var tile = {
         features: [],
diff --git a/src/transform.js b/src/transform.js
index 5ee426a..fe93e94 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -1,8 +1,5 @@
 'use strict';
 
-exports.tile = transformTile;
-exports.point = transformPoint;
-
 // Transforms the coordinates of each feature in the given tile from
 // mercator-projected space into (extent x extent) tile space.
 function transformTile(tile, extent) {
diff --git a/src/wrap.js b/src/wrap.js
index 0eefbb5..cae9609 100644
--- a/src/wrap.js
+++ b/src/wrap.js
@@ -1,8 +1,6 @@
 'use strict';
 
-var clip = require('./clip');
-
-module.exports = wrap;
+const clip = imports.clip.clip;
 
 function wrap(features, buffer, intersectX) {
     var merged = features,
-- 
2.4.0

_______________________________________________
gnome-devel-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-devel-list

Reply via email to