Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nodetiles/nodetiles-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: LocalData/nodetiles-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
Loading
Showing with 3,205 additions and 686 deletions.
  1. +3 −0 .gitignore
  2. +8 −0 .npmignore
  3. +29 −0 README.md
  4. +1 −1 index.js
  5. +16 −15 lib/Map.js
  6. +839 −565 lib/cartoRenderer.js
  7. +70 −0 lib/maptiles.js
  8. +52 −30 lib/projector.js
  9. +46 −41 lib/renderer.js
  10. +22 −22 lib/routes.js
  11. +2,109 −0 package-lock.json
  12. +10 −12 package.json
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@
profile

node_modules
build
npm-debug.log


# pull these data files down separately (they are HUGE and shouldn't be stored in the repo)
geodata
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# osx noise
.DS_Store
profile

node_modules

# pull these data files down separately (they are HUGE and shouldn't be stored in the repo)
geodata
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -70,6 +70,19 @@ map.render({
```

Magic filtering
---------------

To filter objects where a key exists or not, you can use styles with the keyword
'`$undefined`'

```[myfield='$undefined']```

or

```[myfield!='$undefined']```


Thanks
-------

@@ -79,6 +92,22 @@ Projections
-----------
[Supported projections](https://github.com/yuletide/node-proj4js-defs)

Developing
----------

```
npx mocha
```

Common errors
-------------

If you have issues installing canvas on OS X, you may need to explicitly set the path to pkgconfig:

```
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
```

Copyright
---------
Copyright (c) 2012-2014 Code for America. See LICENSE for details.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ module.exports = {
* Transform between projections
*/
projector: projector,

/**
* Routing Middleware
*/
31 changes: 16 additions & 15 deletions lib/Map.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ var BUFFER_RATIO = 0.25;
* map.setStyle(...);
* map.render(0, 0, 180, 90, 500, 250);
*/

// default to EPSG:3857 (web mercator)
// http://spatialreference.org/ref/sr-org/7483/
var DEFAULT_PROJECTION = "EPSG:900913";//"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs";
@@ -38,7 +38,7 @@ var Map = function(options) {

Map.prototype = {
constructor: Map,

render: function(options) {
this._getData(options.bounds, options.boundsBuffer, function(error, shapes) {
if (error) {
@@ -55,7 +55,7 @@ Map.prototype = {
}
}.bind(this));
},

// Should this really be here, or should it exist on a different object entirely?
renderGrid: function(options) {//minX, minY, maxX, maxY, width, height, asImage, callback) {
this._getData(options.bounds, options.boundsBuffer, function(error, shapes) {
@@ -93,11 +93,11 @@ Map.prototype = {
}
dataCallback(error, data);
};

if (typeof datasource !== "function") {
datasource = datasource.getShapes.bind(datasource);
}

// allow simple sources to just return results immediately
var syncData = datasource(dataBounds.minX, dataBounds.minY, dataBounds.maxX, dataBounds.maxY, projection, preCallback);
if (syncData) {
@@ -131,7 +131,7 @@ Map.prototype = {
buffer = BUFFER_RATIO;
}

amount = (bounds.maxX - bounds.minX) * buffer;
var amount = (bounds.maxX - bounds.minX) * buffer;
return {
minX: bounds.minX - amount,
minY: bounds.minY - amount,
@@ -146,15 +146,15 @@ Map.prototype = {
console.warn("Datasource is not a function or an object with a 'getShapes()' function.");
return false;
}

var index = this.datasources.indexOf(datasource);
if (index === -1) {
this.datasources.push(datasource);
return true;
}
return false;
},

removeData: function(datasource) {
var index = this.datasources.indexOf(datasource);
if (index > -1) {
@@ -163,12 +163,12 @@ Map.prototype = {
}
return false;
},

setProjection: function(projection) {
// TODO: validate this somehow?
this.projection = projection;
},

addStyle: function(style) {
// may need to do better flattening, etc.
if (Object.prototype.toString.call(style) === "[object Array]") {
@@ -179,30 +179,31 @@ Map.prototype = {
}
this._processStyles();
},

setRenderer: function(renderer) {
if (renderer.renderImage && renderer.renderGrid && renderer.processStyles) {
this._renderer = renderer;
this._processStyles();
}
},



/**
* Triggers all the map's datasources to prepare themselves. Usually this
* connecting to a database, loading and processing a file, etc.
* Calling this method is completely optional, but allows you to speed up
* Calling this method is completely optional, but allows you to speed up
* rendering of the first tile.
*/
prepare: function() {
var projection = this.projection;

this.datasources.forEach(function(datasource) {
datasource.load && datasource.load(function(error) {
datasource.project && datasource.project(projection);
});
});
},

_processStyles: function() {
this.processedStyles = this._renderer.processStyles(this.styles, this.assetsPath);
}
Loading