-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
f/2840 add durable download linlk #45
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ export type HubSite = { | |
orgBaseUrl: string, | ||
orgTitle: string | ||
}; | ||
|
||
type FileType = 'shapefile' | 'csv' | 'geojson'; | ||
/** | ||
* Mapping from ElasticSearch geo_shape type | ||
* to valid GeoJSON type | ||
|
@@ -79,10 +79,13 @@ export function enrichDataset(dataset: HubDataset, hubsite: HubSite): Feature { | |
|
||
if (isLayer(dataset)) { | ||
additionalFields.accessUrlGeoJSON = downloadLinkFor('geojson'); | ||
additionalFields.durableUrlGeoJSON = generateDurableDownloadUrl(dataset.id, siteUrl, 'geojson'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, do we want to even keep the old links then if we are planning on introducing these durable ones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now yes. Durable links will stay experimental until we finalize the new download service which hasn't been released to production yet and these durable links will only be used for testing hub feeds on DEV and QA as required by the issue 2840. Production hub feeds will be using old links for now. Once, download service gets released to production, these old links will be removed from the provider. |
||
additionalFields.accessUrlCSV = downloadLinkFor('csv'); | ||
additionalFields.durableUrlCSV = generateDurableDownloadUrl(dataset.id, siteUrl, 'csv'); | ||
if (_.has(dataset, 'layer.geometryType')) { | ||
additionalFields.accessUrlKML = downloadLinkFor('kml'); | ||
additionalFields.accessUrlShapeFile = downloadLinkFor('zip'); | ||
additionalFields.durableUrlShapeFile= generateDurableDownloadUrl(dataset.id, siteUrl, 'shapefile'); | ||
} | ||
} | ||
|
||
|
@@ -100,6 +103,11 @@ export function enrichDataset(dataset: HubDataset, hubsite: HubSite): Feature { | |
}); | ||
}; | ||
|
||
function generateDurableDownloadUrl(datasetId: string, siteUrl: string, fileType: FileType) { | ||
const { itemId, layerId } = parseDatasetId(datasetId); | ||
return `https://${siteUrl}/api/download/v1/item/${itemId}/${fileType}?layers=${layerId}`; | ||
} | ||
|
||
function getDatasetKeyword(dataset: HubDataset): string[] { | ||
const metaKeyword = _.get(dataset, 'metadata.metadata.dataIdInfo.searchKeys.keyword'); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally get that you were just copying what existed, but I got really tripped up by the fact that these urls use
arcgis.com
instead ofhub.arcgis.com
(ormy-hub-site.com
, etc.). This is mainly because the download APIs are provided by us, not ArcGIS Online. Would you mind updating for consistency?