Skip to content

Commit a38a24e

Browse files
added vector tiles support
1 parent 942ca8f commit a38a24e

File tree

4 files changed

+85
-7
lines changed

4 files changed

+85
-7
lines changed

jobs/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def validate_export_formats(value):
9595
"shp",
9696
"geojson",
9797
"fgb",
98+
"mvt",
99+
"pmtiles",
98100
"csv",
99101
"sql",
100102
"geopackage",

tasks/task_runners.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def finish_task(name, created_files=None, response_back=None, planet_file=False)
254254
total_bytes += file.size()
255255
task.filesize_bytes = total_bytes
256256
LOG.debug(total_bytes)
257-
257+
258258
task.save()
259259

260260
is_hdx_export = HDXExportRegion.objects.filter(job_id=run.job_id).exists()
@@ -271,6 +271,8 @@ def finish_task(name, created_files=None, response_back=None, planet_file=False)
271271
"kml",
272272
"shp",
273273
"fgb",
274+
"mvt",
275+
"pmtiles",
274276
"csv",
275277
"sql",
276278
"mbtiles",
@@ -934,6 +936,66 @@ def add_metadata(z, theme):
934936
stop_task("mbtiles")
935937
raise ex
936938

939+
if "pmtiles" in export_formats:
940+
try:
941+
pmtiles = Galaxy(
942+
settings.RAW_DATA_API_URL,
943+
geom,
944+
mapping=mapping_filter,
945+
file_name=valid_name,
946+
access_token=settings.RAW_DATA_ACCESS_TOKEN,
947+
)
948+
start_task("pmtiles")
949+
LOG.debug(
950+
"Raw Data API fetch started for pmtiles run: {0}".format(run_uid)
951+
)
952+
all_feature_filter_json = join(
953+
os.getcwd(), "tasks/tests/fixtures/all_features_filters.json"
954+
)
955+
response_back = pmtiles.fetch(
956+
"pmtiles",
957+
all_feature_filter_json=all_feature_filter_json,
958+
min_zoom=job.mbtiles_minzoom,
959+
max_zoom=job.mbtiles_maxzoom,
960+
)
961+
write_file_size(response_back)
962+
LOG.debug(
963+
"Raw Data API fetch ended for mbtiles run: {0}".format(run_uid)
964+
)
965+
finish_task("pmtiles", response_back=response_back)
966+
967+
except Exception as ex:
968+
stop_task("pmtiles")
969+
raise ex
970+
971+
if "mvt" in export_formats:
972+
try:
973+
mvt = Galaxy(
974+
settings.RAW_DATA_API_URL,
975+
geom,
976+
mapping=mapping_filter,
977+
file_name=valid_name,
978+
access_token=settings.RAW_DATA_ACCESS_TOKEN,
979+
)
980+
start_task("mvt")
981+
LOG.debug("Raw Data API fetch started for mvt run: {0}".format(run_uid))
982+
all_feature_filter_json = join(
983+
os.getcwd(), "tasks/tests/fixtures/all_features_filters.json"
984+
)
985+
response_back = mvt.fetch(
986+
"mvt",
987+
all_feature_filter_json=all_feature_filter_json,
988+
min_zoom=job.mbtiles_minzoom,
989+
max_zoom=job.mbtiles_maxzoom,
990+
)
991+
write_file_size(response_back)
992+
LOG.debug("Raw Data API fetch ended for mvt run: {0}".format(run_uid))
993+
finish_task("mvt", response_back=response_back)
994+
995+
except Exception as ex:
996+
stop_task("mvt")
997+
raise ex
998+
937999
if use_only_galaxy == False:
9381000
LOG.debug("Source start for run: {0}".format(run_uid))
9391001
source_path = source.path()

ui/app/components/help/ExportFormats.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default () =>
101101
</ul>
102102
</div>
103103
<div>
104-
<h2 id="gpkg">GeoJSON .geojson</h2>
104+
<h2 id="geojson">GeoJSON .geojson</h2>
105105
<p>
106106
GeoJSON is an open standard geospatial data interchange format that represents simple geographic features and their nonspatial attributes. Based on JavaScript Object Notation (JSON), GeoJSON is a format for encoding a variety of geographic data structures. It uses a geographic coordinate reference system, World Geodetic System 1984, and units of decimal degrees.
107107
</p>
@@ -142,7 +142,7 @@ export default () =>
142142
</ul>
143143
</div>
144144
<div>
145-
<h2 id="gpkg">FlatGeobuf .fgb</h2>
145+
<h2 id="fgb">FlatGeobuf .fgb</h2>
146146
<p>
147147
FlatGeobuf is a binary file format for storing geospatial vector data in a compact and efficient manner. It uses a hierarchical structure to organize features into layers, and stores attribute data in a separate file.
148148
</p>
@@ -183,7 +183,7 @@ export default () =>
183183
</ul>
184184
</div>
185185
<div>
186-
<h2 id="gpkg">CSV .csv</h2>
186+
<h2 id="csv">CSV .csv</h2>
187187
<p>
188188
CSV is a file format for storing tabular data in plain text format. Each row of data represents a record, and each column represents a field of that record. CSV files are widely used because they are simple and easy to create and manipulate, making them a popular choice for data exchange. </p>
189189
<h4>
@@ -203,7 +203,7 @@ export default () =>
203203
</ul>
204204
</div>
205205
<div>
206-
<h2 id="gpkg">SQL .sql</h2>
206+
<h2 id="sql">SQL .sql</h2>
207207
<p>
208208
SQL files are plain text files that contain SQL commands to create, modify or interact with a relational database. They can be used to define database schemas, constraints, and indexes, as well as to insert, update, and query data.
209209
</p>

ui/app/components/utils.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ export const AVAILABLE_EXPORT_FORMATS = {
6363
MBTiles <code>.mbtiles</code>
6464
</span>
6565
),
66+
pmtiles: (
67+
<span key="pmtiles">
68+
Pmtiles <code>.pmtiles</code>
69+
</span>
70+
),
71+
mvt: (
72+
<span key="mvt">
73+
Mapbox Vector Tiles <code>.mvt</code>
74+
</span>
75+
),
6676
garmin_img: (
6777
<span key="garmin_img">
6878
Garmin <code>.img</code>
@@ -99,6 +109,8 @@ export const REQUIRES_FEATURE_SELECTION = {
99109
shp: true,
100110
geojson:true,
101111
fgb:true,
112+
mvt:true,
113+
pmtiles:true,
102114
sql:true,
103115
csv:true,
104116
geopackage: true,
@@ -110,12 +122,14 @@ export const REQUIRES_FEATURE_SELECTION = {
110122
};
111123

112124
export const REQUIRES_TILE_SOURCE = {
113-
mbtiles: true
125+
mbtiles: true,
126+
pmtiles:true,
127+
mvt:true,
114128
};
115129

116130
export const OMIT_FROM_FORMAT_OPTIONS = {
117131
osm_xml: true,
118-
bundle: true
132+
bundle: true
119133
};
120134

121135
export const getRootUrl = () => {

0 commit comments

Comments
 (0)