Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Observatoire
observatoire-scripts
Commits
6628652f
Commit
6628652f
authored
Mar 04, 2020
by
Pierre Dittgen
Browse files
compact geojson files reducing float precision
parent
72da942b
Pipeline
#1795
passed with stages
in 147 minutes and 34 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/legacy/generate_geo_jsons.py
View file @
6628652f
...
@@ -4,9 +4,11 @@
...
@@ -4,9 +4,11 @@
"""
"""
import
argparse
import
argparse
import
io
import
io
import
ujson
as
json
from
pathlib
import
Path
import
sqlite3
import
sqlite3
from
pathlib
import
Path
import
ujson
as
json
import
metrics_common
as
mc
import
metrics_common
as
mc
GEOJSON_HEADER
=
"""
GEOJSON_HEADER
=
"""
...
@@ -40,7 +42,6 @@ def compute_description(row, met_cursor):
...
@@ -40,7 +42,6 @@ def compute_description(row, met_cursor):
def
manage_geom
(
geo_string
):
def
manage_geom
(
geo_string
):
""" return geometry data """
""" return geometry data """
# decode
# decode
return
json
.
loads
(
geo_string
)
return
json
.
loads
(
geo_string
)
...
@@ -60,7 +61,7 @@ def output_feature(fd, row, metrics_cursor):
...
@@ -60,7 +61,7 @@ def output_feature(fd, row, metrics_cursor):
'geometry'
:
manage_geom
(
row
[
'coords'
]),
'geometry'
:
manage_geom
(
row
[
'coords'
]),
}
}
fd
.
write
(
json
.
dumps
(
feature_data
,
ensure_ascii
=
False
,
indent
=
2
,
sort_keys
=
True
))
fd
.
write
(
json
.
dumps
(
feature_data
,
ensure_ascii
=
False
,
sort_keys
=
True
,
double_precision
=
2
))
def
generate_geojson_file
(
category
,
conn
,
geojson_filepath
:
Path
):
def
generate_geojson_file
(
category
,
conn
,
geojson_filepath
:
Path
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment