-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from hotosm/refactor/multipleCustomviz
Refactor for custom visualizations for HDX custom exports
- Loading branch information
Showing
11 changed files
with
115 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,24 @@ | ||
from geojson_stats.stats import Stats | ||
from geojson_stats.html import Html | ||
|
||
CONFIG_AREA = ["building"] | ||
CONFIG_LENGTH = ["highway", "waterway"] | ||
|
||
|
||
class GeoJSONStats(Stats): | ||
"""Used for collecting stats while processing GeoJSON files line by line""" | ||
"""Used for collecting stats while processing GeoJSON files""" | ||
|
||
def __init__(self, filters, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
self.config.clean = True | ||
self.config.properties_prop = "properties.tags" | ||
|
||
if filters and filters.tags: | ||
for tag in CONFIG_AREA: | ||
if self.check_filter(filters.tags, tag): | ||
self.config.keys.append(tag) | ||
self.config.value_keys.append(tag) | ||
self.config.area = True | ||
|
||
for tag in CONFIG_LENGTH: | ||
if self.check_filter(filters.tags, tag): | ||
self.config.keys.append(tag) | ||
self.config.value_keys.append(tag) | ||
self.config.length = True | ||
|
||
def check_filter(self, tags, tag): | ||
""" | ||
Check if a tag is present in tag filters | ||
""" | ||
|
||
if tags.all_geometry: | ||
if tags.all_geometry.join_or and tag in tags.all_geometry.join_or: | ||
return True | ||
if tags.all_geometry.join_and and tag in tags.all_geometry.join_and: | ||
return True | ||
if tags.polygon: | ||
if tags.polygon.join_or and tag in tags.polygon.join_or: | ||
return True | ||
if tags.polygon.join_and and tag in tags.polygon.join_and: | ||
return True | ||
if tags.line: | ||
if tags.line.join_or and tag in tags.line.join_or: | ||
return True | ||
if tags.line.join_and and tag in tags.line.join_and: | ||
return True | ||
|
||
def raw_data_line_stats(self, json_object: dict): | ||
""" | ||
Process a GeoJSON line (for getting stats) and return that line | ||
""" | ||
self.get_object_stats(json_object) | ||
|
||
def html(self, tpl): | ||
def html(self, tpl, tpl_params): | ||
""" | ||
Returns stats Html object, generated from stats data using a template | ||
""" | ||
return Html(tpl, self) | ||
return Html(tpl, self, tpl_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.