Skip to content

Commit

Permalink
added vector tiles support
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Aug 28, 2024
1 parent 942ca8f commit a38a24e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 7 deletions.
2 changes: 2 additions & 0 deletions jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def validate_export_formats(value):
"shp",
"geojson",
"fgb",
"mvt",
"pmtiles",
"csv",
"sql",
"geopackage",
Expand Down
64 changes: 63 additions & 1 deletion tasks/task_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def finish_task(name, created_files=None, response_back=None, planet_file=False)
total_bytes += file.size()
task.filesize_bytes = total_bytes
LOG.debug(total_bytes)

task.save()

is_hdx_export = HDXExportRegion.objects.filter(job_id=run.job_id).exists()
Expand All @@ -271,6 +271,8 @@ def finish_task(name, created_files=None, response_back=None, planet_file=False)
"kml",
"shp",
"fgb",
"mvt",
"pmtiles",
"csv",
"sql",
"mbtiles",
Expand Down Expand Up @@ -934,6 +936,66 @@ def add_metadata(z, theme):
stop_task("mbtiles")
raise ex

if "pmtiles" in export_formats:
try:
pmtiles = Galaxy(
settings.RAW_DATA_API_URL,
geom,
mapping=mapping_filter,
file_name=valid_name,
access_token=settings.RAW_DATA_ACCESS_TOKEN,
)
start_task("pmtiles")
LOG.debug(
"Raw Data API fetch started for pmtiles run: {0}".format(run_uid)
)
all_feature_filter_json = join(
os.getcwd(), "tasks/tests/fixtures/all_features_filters.json"
)
response_back = pmtiles.fetch(
"pmtiles",
all_feature_filter_json=all_feature_filter_json,
min_zoom=job.mbtiles_minzoom,
max_zoom=job.mbtiles_maxzoom,
)
write_file_size(response_back)
LOG.debug(
"Raw Data API fetch ended for mbtiles run: {0}".format(run_uid)
)
finish_task("pmtiles", response_back=response_back)

except Exception as ex:
stop_task("pmtiles")
raise ex

if "mvt" in export_formats:
try:
mvt = Galaxy(
settings.RAW_DATA_API_URL,
geom,
mapping=mapping_filter,
file_name=valid_name,
access_token=settings.RAW_DATA_ACCESS_TOKEN,
)
start_task("mvt")
LOG.debug("Raw Data API fetch started for mvt run: {0}".format(run_uid))
all_feature_filter_json = join(
os.getcwd(), "tasks/tests/fixtures/all_features_filters.json"
)
response_back = mvt.fetch(
"mvt",
all_feature_filter_json=all_feature_filter_json,
min_zoom=job.mbtiles_minzoom,
max_zoom=job.mbtiles_maxzoom,
)
write_file_size(response_back)
LOG.debug("Raw Data API fetch ended for mvt run: {0}".format(run_uid))
finish_task("mvt", response_back=response_back)

except Exception as ex:
stop_task("mvt")
raise ex

if use_only_galaxy == False:
LOG.debug("Source start for run: {0}".format(run_uid))
source_path = source.path()
Expand Down
8 changes: 4 additions & 4 deletions ui/app/components/help/ExportFormats.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default () =>
</ul>
</div>
<div>
<h2 id="gpkg">GeoJSON .geojson</h2>
<h2 id="geojson">GeoJSON .geojson</h2>
<p>
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.
</p>
Expand Down Expand Up @@ -142,7 +142,7 @@ export default () =>
</ul>
</div>
<div>
<h2 id="gpkg">FlatGeobuf .fgb</h2>
<h2 id="fgb">FlatGeobuf .fgb</h2>
<p>
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.
</p>
Expand Down Expand Up @@ -183,7 +183,7 @@ export default () =>
</ul>
</div>
<div>
<h2 id="gpkg">CSV .csv</h2>
<h2 id="csv">CSV .csv</h2>
<p>
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>
<h4>
Expand All @@ -203,7 +203,7 @@ export default () =>
</ul>
</div>
<div>
<h2 id="gpkg">SQL .sql</h2>
<h2 id="sql">SQL .sql</h2>
<p>
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.
</p>
Expand Down
18 changes: 16 additions & 2 deletions ui/app/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export const AVAILABLE_EXPORT_FORMATS = {
MBTiles <code>.mbtiles</code>
</span>
),
pmtiles: (
<span key="pmtiles">
Pmtiles <code>.pmtiles</code>
</span>
),
mvt: (
<span key="mvt">
Mapbox Vector Tiles <code>.mvt</code>
</span>
),
garmin_img: (
<span key="garmin_img">
Garmin <code>.img</code>
Expand Down Expand Up @@ -99,6 +109,8 @@ export const REQUIRES_FEATURE_SELECTION = {
shp: true,
geojson:true,
fgb:true,
mvt:true,
pmtiles:true,
sql:true,
csv:true,
geopackage: true,
Expand All @@ -110,12 +122,14 @@ export const REQUIRES_FEATURE_SELECTION = {
};

export const REQUIRES_TILE_SOURCE = {
mbtiles: true
mbtiles: true,
pmtiles:true,
mvt:true,
};

export const OMIT_FROM_FORMAT_OPTIONS = {
osm_xml: true,
bundle: true
bundle: true
};

export const getRootUrl = () => {
Expand Down

0 comments on commit a38a24e

Please sign in to comment.