Skip to content

Commit 2dd6673

Browse files
authored
Merge pull request #1 from BrianHepler/Data-Fixes
Data fixes.
2 parents 6e56fd6 + 18718de commit 2dd6673

4 files changed

Lines changed: 45 additions & 10 deletions

File tree

MMM-BirdNET.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Module.register("MMM-BirdNET", {
99
lon: -76.47363144,
1010
width: '400px',
1111
height: '400px',
12-
zoomLevel: 7
12+
zoomLevel: 7,
13+
markerDistance: 300,
14+
markerColor: 'LightGreen' // distance from map center to put markers
1315
},
1416

1517
start: function () {
@@ -26,6 +28,7 @@ Module.register("MMM-BirdNET", {
2628
this.birdData = {};
2729
this.birdMap = null;
2830
this.markersLayer = new L.layerGroup();
31+
this.locations = [];
2932

3033
this.popupOptions = {
3134
closeButton: false,
@@ -111,6 +114,9 @@ Module.register("MMM-BirdNET", {
111114

112115
this.birdData = JSON.parse(birdData);
113116
var markers = this.markersLayer;
117+
this.locations = [];
118+
var skipped = 0;
119+
var markerRadius = this.birdMap.getZoom() - 2;
114120
markers.clearLayers(); // clear markers ahead of data load
115121

116122
var observations = this.birdData.observations;
@@ -119,21 +125,35 @@ Module.register("MMM-BirdNET", {
119125
var lat = entry.lat;
120126
var lon = entry.lon;
121127
var dist = this.getDistance(this.config.lat,this.config.lon, lat, lon);
122-
if (dist < 300) { // remove entries further than 300 km
128+
if (dist < this.config.markerDistance) { // remove entries further than 300 km
129+
// ensure only one marker per lat/lon to nearest 10th.
130+
var loc_code = ((lat * 5).toFixed(0) / 5) + ";" + ((lon * 5).toFixed(0) / 5);
131+
if (this.locations.includes(loc_code)) {
132+
skipped++;
133+
continue;
134+
} else (this.locations.push(loc_code));
135+
123136
// split species into common & Latin
124137
var species_split = entry.species.split(";");
125138
var name = species_split[0];
126139
var species = species_split[1];
127140
var percent = entry.score;
128141
var ts = entry.ts;
129142

130-
var marker = L.marker([lat, lon]);
143+
// var marker = L.marker([lat, lon]);
144+
var circle = L.circleMarker([lat,lon], {
145+
stroke: false,
146+
fill: true,
147+
fillColor: this.config.markerColor,
148+
radius: markerRadius,
149+
fillOpacity: 1
150+
});
131151
var popup = this.createPopup(name, species, percent, ts);
132-
marker.bindPopup(popup, this.popupOptions);
133-
markers.addLayer(marker);
134-
}
152+
circle.bindPopup(popup, this.popupOptions);
153+
markers.addLayer(circle);
154+
} else { skipped++;}
135155
}
136-
this.schedulePopInterval();
156+
Log.info("Processed " + observations.length + " bird hits. (skipped " + skipped +")");
137157
},
138158

139159
createPopup: function(name, species, percent, ts) {
@@ -256,6 +276,7 @@ Module.register("MMM-BirdNET", {
256276
this.loaded = true;
257277
this.buildMap();
258278
this.updateData();
279+
this.schedulePopInterval();
259280
}
260281
},
261282

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,33 @@ All configuration options are optional. There are no mandatory parameters.
3434
|:------:| ------- | ----------- |
3535
| updateInterval | 3600000 (one hour) | How often the BirdNET data is pulled from the website.|
3636
| popInterval | 30000 (30 seconds)| How often the popup switches to a new entry |
37-
| dataUrl | https://birdnet.cornell.edu/map/requeststats| Where to pull the data |
3837
| mapMode | 'dark' | Which map to use. Supported values are: `dark`, `light`, `atlas`, `stark`, `terrain`, `satellite`, `custom` and `metal`.
3938
| lat | 42.453583743 | Latitude for the center of the map display. |
40-
| lon | -76.47363144 | Longitude for the center of the map display. |
39+
| lon | -76.47363144 | Longitude for the center of the map display. |
4140
| width | 400px | Width of the map box. |
4241
| height | 400px | Height of the map box |
42+
| markerColor | 'LightGreen' | Sets the color of the markers on the map representing submissions. Accepts [HTML standard color names](https://www.w3schools.com/cssref/css_colors.php) or hex format.|
43+
| markerDistance | 300 | Distance in kilometers from the center of the map to display BirdNET submissions. If you encounter performance issues, try reducing this number. BirdNET regularly receives 30-50K submissions daily and we can _maybe_ display 10K. |
4344
| zoomLevel | 7 | How far in the map is zoomed. See [Leaflet](https://leafletjs.com/examples/zoom-levels/) documentation for more details. |
4445
| mapUrl | null | If you set the mapMode parameter to `custom`, this parameter will activate. You can supply your own [Leaflet](https://leafletjs.com/reference.html#map-example)-supported map URL here. |
46+
| dataUrl | https://birdnet.cornell.edu/map/requeststats| Where to pull the data |
4547

4648
## Upcoming Features
4749
* Better CSS for the popups.
4850
* Enable notification broadcasts
4951

52+
## Version History
53+
### v0.1.1
54+
* Fixed issue with popups double-tapping after an hour
55+
* Fixed issue with displaying submissions in exceptionally high-density areas
56+
* Submission markers are now dots instead of map markers
57+
* Can set marker color with `markerColor` parameter
58+
* Can set distance limit on which markers are displayed with `markerDistance` parameter
59+
60+
### v0.1.0
61+
* Initial release
62+
63+
5064
## Thanks To
5165
* [thgmirror](https://forum.magicmirror.builders/user/thgmirror) over at the MagicMirror Forum for the inspiration.
5266
* [cyberdie](https://forum.magicmirror.builders/user/cyberdie) for the idea about the bird images.

display.png

-35.7 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mmm-birdnet",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "A display of local hits for the BirdNET mobile app. https://birdnet.cornell.edu",
55
"main": "MMM-BirdNET.js",
66
"repository": {

0 commit comments

Comments
 (0)