Skip to content

Commit

Permalink
Merge pull request #4 from inaturalist/markers
Browse files Browse the repository at this point in the history
New cartography
  • Loading branch information
kueda committed Aug 24, 2015
2 parents 1b98b2c + 76ca6e7 commit d6be515
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 2,004 deletions.
8 changes: 8 additions & 0 deletions lib/assets/map-marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/assets/mm_34_stemless_unknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/assets/mm_34_unknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions lib/assets/rounded_marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions lib/assets/rounded_marker_with_hole.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/inaturalist_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ InaturalistAPI.elasticResults = function( req, index, callback ) {
};

InaturalistAPI.defaultMapFields = function( ) {
return [ "id", "location", "taxon.iconic_taxon_id", "captive", "quality_grade" ];
return [ "id", "location", "taxon.iconic_taxon_id", "captive",
"quality_grade", "geoprivacy" ];
};

InaturalistAPI.fetchIDs = function( req, indexName, callback ) {
Expand Down
24 changes: 3 additions & 21 deletions lib/inaturalist_map_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,6 @@ InaturalistMapserver.prepareQuery = function( req, callback ) {
var elastic_query = InaturalistAPI.paramsToElasticQuery( req.query );
var searchHash = esClient.searchHash( elastic_query );
req.elastic_query.query = searchHash.query;
if( req.params.zoom >= 8 ) {
if( req.elastic_query.query.filtered ) {
if( req.elastic_query.query.filtered.filter.bool ) {
req.elastic_query.query.filtered.filter.bool.must.push(
{ not: { exists: { field: "private_location" } } });
} else {
console.log( "this query has a problem with zooms over 8:" );
console.log( JSON.stringify( req.elastic_query.query.filtered, null, " " ) );
}
} else {
req.elastic_query.query = {
filtered: {
query: req.elastic_query.query,
filter: { bool: { must: [ { not: { exists: { field: "private_location" } } } ] } }
}
};
}
}

switch( req.params.style ) {
case "heatmap":
Expand All @@ -117,7 +99,7 @@ InaturalistMapserver.prepareStyle = function( req, callback ) {
req.style = MapStyles.heatmap( req.query.color );
break;
case "summary":
req.style = MapStyles.coloredHeatmap( "#6E6E6E", 8 );
req.style = MapStyles.coloredHeatmap( "#6E6E6E", 8, 0.2 );
break;
case "colored_heatmap":
var color;
Expand All @@ -144,8 +126,8 @@ InaturalistMapserver.prepareStyle = function( req, callback ) {
} else if( req.taxon ) {
color = util.iconicTaxonColors[ req.taxon.iconic_taxon_id ];
}
if( color ) { req.style = MapStyles.coloredPoints( color ); }
else { req.style = MapStyles.points( ); }
if( color ) { req.style = MapStyles.markersAndCircles( color ); }
else { req.style = MapStyles.markersAndCircles( ); }
}
callback( null, req );
};
Expand Down
2,080 changes: 102 additions & 1,978 deletions lib/inaturalist_map_styles.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"socket.io": "^1.3.5",
"moment": "^2.10.3",
"jade": "^1.11.0",
"newrelic": "~1.21.1"
"newrelic": "~1.21.1",
"carto": "^0.14.1"
},
"devDependencies": {
"mocha": "^2.2.4",
Expand Down
2 changes: 1 addition & 1 deletion test/inaturalist_map_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe( "InaturalistMapServer", function( ) {
stubReq.params.style = "summary";
MapServer.prepareStyle( stubReq, function( err, req ) {
expect( stubReq.style ).to.eql(
MapStyles.coloredHeatmap( "#6E6E6E", 8 ) );
MapStyles.coloredHeatmap( "#6e6e6e", 8 ) );
done( );
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/inaturalist_map_styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( "InaturalistMapStyles", function( ) {

describe( "coloredPoints", function( ) {
it( "defaults to gray", function( ) {
expect( MapStyles.coloredPoints( ) ).to.include( "#6E6E6E" );
expect( MapStyles.coloredPoints( ) ).to.include( "#6e6e6e" );
});

it( "uses a heatmap styled colorize-alpha filter", function( ) {
Expand All @@ -24,7 +24,7 @@ describe( "InaturalistMapStyles", function( ) {

describe( "points", function( ) {
it( "returns a style with the right name", function( ) {
expect( MapStyles.points( ) ).to.include( "Style name='style'" );
expect( MapStyles.points( ) ).to.include( "Style name=\"style\"" );
});
});

Expand Down

0 comments on commit d6be515

Please sign in to comment.