Skip to content

Commit

Permalink
fixed obscured style for threated taxon observations
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Aug 26, 2015
1 parent d6be515 commit 3c90597
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/inaturalist_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ InaturalistAPI.elasticResults = function( req, index, callback ) {

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

InaturalistAPI.fetchIDs = function( req, indexName, callback ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/inaturalist_map_styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ InaturalistMapStyles.markersAndCircles = function( color ) {
"[quality_grade='research'] { fg/marker-line-width: 0; fg/marker-width: 2; fg/marker-fill: #ffffff; " +
" fg/marker-fill-opacity: 1; fg/marker-allow-overlap: true; fg/marker-transform: translate(0,-26); "+
" marker-line-color: #ffffff; } " +
"[geoprivacy='obscured']{ marker-file: ''; marker-line-width: 1.5; marker-transform: translate(0,0); "+
"[geoprivacy='obscured'],[private_location!='']{ marker-file: ''; marker-line-width: 1.5; marker-transform: translate(0,0); "+
" marker-width: 10; marker-line-color: #BDBDBD; marker-fill-opacity: 0.3; fg/marker-transform: translate(0,0); } " +
"['taxon.iconic_taxon_id'=''][geoprivacy='obscured'] { marker-file: 'lib/assets/mm_34_stemless_unknown.png'; marker-width: 11; } " +
"['taxon.iconic_taxon_id'=''] { marker-file: 'lib/assets/mm_34_unknown.png'; marker-width: 9; } ";
Expand Down
3 changes: 2 additions & 1 deletion test/inaturalist_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ describe( "InaturalistAPI", function( ) {
describe( "defaultMapFields", function( ) {
it( "returns the proper default select fields", function( ) {
expect( InaturalistAPI.defaultMapFields( ) ).to.eql( [ "id", "location",
"taxon.iconic_taxon_id", "captive", "quality_grade" ]);
"taxon.iconic_taxon_id", "captive", "quality_grade", "geoprivacy",
"private_location" ]);
});
});

Expand Down
27 changes: 10 additions & 17 deletions test/inaturalist_map_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe( "InaturalistMapServer", function( ) {
expect( stubReq.elastic_query.aggregations.zoom1 ).to.eql({
aggs: { geohash: { top_hits: { _source: false,
fielddata_fields: [
"id", "location", "taxon.iconic_taxon_id", "captive", "quality_grade" ],
"id", "location", "taxon.iconic_taxon_id", "captive", "quality_grade",
"geoprivacy", "private_location" ],
size: 1, sort: { id: { order: "desc" } } } } },
geohash_grid: { field: "location", precision: 3, size: 50000 }
});
Expand All @@ -64,7 +65,8 @@ describe( "InaturalistMapServer", function( ) {
expect( stubReq.elastic_query.aggregations.zoom1 ).to.eql({
aggs: { geohash: { top_hits: { _source: false,
fielddata_fields: [
"id", "location", "taxon.iconic_taxon_id", "captive", "quality_grade" ],
"id", "location", "taxon.iconic_taxon_id", "captive", "quality_grade",
"geoprivacy", "private_location" ],
size: 1, sort: { id: { order: "desc" } } } } },
geohash_grid: { field: "location", precision: 3, size: 50000 }
});
Expand All @@ -86,30 +88,21 @@ describe( "InaturalistMapServer", function( ) {
done( );
});
});

it( "filters out obscured coordinates at zoom 8", function( done ) {
stubReq.params.zoom = 8;
MapServer.prepareQuery( stubReq, function( err ) {
expect( stubReq.elastic_query.query.filtered.filter.bool.must ).to.eql([
{ not: { exists: { field: "private_location" } } }]);
done( );
});
});
});

describe( "prepareStyle", function( ) {
it( "defaults to points style", function( done ) {
it( "defaults to points markersAndCircles", function( done ) {
MapServer.prepareStyle( stubReq, function( err, req ) {
expect( stubReq.style ).to.eql( MapStyles.points( ) );
expect( stubReq.style ).to.eql( MapStyles.markersAndCircles( ) );
done( );
});
});

it( "can specify color of points style", function( done ) {
it( "can specify color of default style", function( done ) {
stubReq.query.color = "#123FED";
MapServer.prepareStyle( stubReq, function( err, req ) {
expect( stubReq.style ).to.eql(
MapStyles.coloredPoints( stubReq.query.color ) );
MapStyles.markersAndCircles( stubReq.query.color ) );
done( );
});
});
Expand All @@ -118,7 +111,7 @@ describe( "InaturalistMapServer", function( ) {
stubReq.taxon = { iconic_taxon_id: 1 };
MapServer.prepareStyle( stubReq, function( err, req ) {
expect( stubReq.style ).to.eql(
MapStyles.coloredPoints( "#1E90FF" ) );
MapStyles.markersAndCircles( "#1E90FF" ) );
done( );
});
});
Expand All @@ -135,7 +128,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, 0.2 ) );
done( );
});
});
Expand Down
10 changes: 2 additions & 8 deletions test/inaturalist_map_styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ describe( "InaturalistMapStyles", function( ) {

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

it( "uses a heatmap styled colorize-alpha filter", function( ) {
expect( MapStyles.coloredPoints( "#555555") ).to.include( "#555555" );
});
});

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

Expand Down

0 comments on commit 3c90597

Please sign in to comment.