Skip to content

Commit

Permalink
added third party libs as part of compiled source for polygon lookup,…
Browse files Browse the repository at this point in the history
… which isn't working yet
  • Loading branch information
robertleeplummerjr committed Jan 2, 2016
1 parent feac329 commit 180cdf8
Show file tree
Hide file tree
Showing 5 changed files with 986 additions and 17 deletions.
5 changes: 5 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@
"earcut": "https://github.com/mapbox/earcut.git#~2.0.7",
"leaflet": "~0.7.5",
"rbush": "https://github.com/mourner/rbush.git#~1.4.2"
},
"devDependencies": {
"rbush": "https://github.com/mourner/rbush.git#~1.4.2",
"polygon-lookup": "https://github.com/pelias/polygon-lookup.git",
"point-in-polygon": "https://github.com/substack/point-in-polygon.git#~1.0.0"
}
}
48 changes: 43 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@ function glslMin(src) {
+ '"';
}

//because I didn't want to include the whole of node or of browserify just to get a few tiny scripts...
function deNodeify(rawSrc, name) {
var src = rawSrc
//get rid of require, they will be included globally
.replace(/[\n]*var[ ]+\w+[ ]+[=][ ]+require[ ]*[(].+;/g, '')

//make module.exports a return, to protect scope
.replace(/module[.]exports[ ]+[=]/, 'return');

if (name) {
return '\nwindow.' + name + ' = (function() {\n' + ( src ) + '\n})();';
} else {
return src;
}
}

readFiles([
//src files
'src/js/glify.js',
'src/js/canvasoverlay.js',
'src/js/glify/points.js',
Expand All @@ -45,7 +62,13 @@ readFiles([

'src/shader/fragment/polygon.glsl',

'src/shader/vertex.glsl'
'src/shader/vertex.glsl',

//node dependencies
'bower_components/rbush/rbush.js',
'bower_components/point-in-polygon/index.js',
'bower_components/polygon-lookup/lib/polygon_utils.js',
'bower_components/polygon-lookup/index.js'
],
function(
glifySrc,
Expand All @@ -61,10 +84,17 @@ readFiles([

polygonSrc,

vertexSrc) {
vertexSrc,

rbush,
pointInPolygon,
polygonUtils,
PolygonLookup
) {

glifySrc = glifySrc
.replace('//top-message', '//this file was auto generated, any edits to it will be lost when you run `node build.js`')
.replace('//top-message', '/*this file was auto generated, any edits to it will be lost when you run `node build.js`\n\
please submit pull requests by first editing src/* and then running `node build.js`*/')
.replace('Points: null' , 'Points: ' + pointsSrc)
.replace('Shapes: null' , 'Shapes: ' + shapesSrc)
.replace('mapMatrix: null', 'mapMatrix: ' + mapMatrixSrc)
Expand All @@ -76,9 +106,17 @@ readFiles([
.replace('simpleCircle: null', 'simpleCircle: ' + glslMin(simpleCircleSrc))
.replace('square: null' , 'square: ' + glslMin(squareSrc))

.replace('polygon: null', 'polygon: ' + glslMin(polygonSrc));
.replace('polygon: null', 'polygon: ' + glslMin(polygonSrc))

+ canvasoverlaySrc

+ '\n\n//third party libraries\n\n'
+ deNodeify(rbush)
+ deNodeify(pointInPolygon, 'pointInPolygon')
+ deNodeify(polygonUtils, 'polygonUtils')
+ deNodeify(PolygonLookup, 'PolygonLookup');

fs.writeFile('glify.js', glifySrc + canvasoverlaySrc, function(err) {
fs.writeFile('glify.js', glifySrc, function(err) {
if (err) throw err;

console.log('done');
Expand Down
Loading

0 comments on commit 180cdf8

Please sign in to comment.