Skip to content

Commit

Permalink
Merge pull request #515 from Esri/2.7.1
Browse files Browse the repository at this point in the history
fix stac api content-type
  • Loading branch information
mhogeweg authored Dec 21, 2023
2 parents 0864840 + 4086583 commit 3c6e4fa
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 165 deletions.
6 changes: 2 additions & 4 deletions geoportal-search/src/main/resources/gs/widget/ItemCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ function(declare, array, locale, domClass, _WidgetBase, _TemplatedMixin,
"mapserver": "Map Service",
"map service": "Map Service",
"wms": "WMS",
"kml": "KML"
/*
"kml": "KML",
"vectortileserver": "Vector Tile Service",
"vector tile service": "Vector Tile Service",
*/
"vector tile service": "Vector Tile Service"
};

this.referenceId = response.sourceKey+"-refid-"+item.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Response getCollectionMetadata(@Context HttpServletRequest hsr,
}

@GET
@Produces("application/json")
@Produces("application/geo+json")
@Path("/collections/{collectionId}/items")
public Response getItems(@Context HttpServletRequest hsr,
@PathParam("collectionId") String collectionId,
Expand Down Expand Up @@ -230,7 +230,7 @@ public Response getItems(@Context HttpServletRequest hsr,
status = Response.Status.INTERNAL_SERVER_ERROR;
responseJSON = this.generateResponse("500", "STAC API collection metadata items response could not be generated.");
}
return Response.status(status).header("Content-Type", "application/json").entity(responseJSON).build();
return Response.status(status).header("Content-Type", "application/geo+json").entity(responseJSON).build();
}

@GET
Expand Down
2 changes: 1 addition & 1 deletion geoportal/src/main/resources/metadata/js/Evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ G._metadataTypes = {
evaluator: G.evaluators.arcgis,
interrogationXPath: "/metadata/Esri/ArcGISFormat",
identifier: "ArcGIS-Metadata",
detailsXslt: "metadata/details/arcgis-details.xslt",
detailsXslt: "metadata/details/arcgis-details.xslt"
},
"oai_dc": {
key: "oai_dc",
Expand Down
26 changes: 25 additions & 1 deletion geoportal/src/main/resources/metadata/js/EvaluatorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ var G = {
} else if (lc.indexOf("/rest/services/") > 0) {
for (i=0;i<arcgisTypes.length;i++) {
v = "/"+arcgisTypes[i].toLowerCase();
if (endsWith(lc,v)) {
if ((endsWith(lc,v)) || (lc.indexOf(v + "/") > 0)) {
linkType = arcgisTypes[i];
linkUrl = url;
break;
Expand All @@ -177,6 +177,30 @@ var G = {
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("cuahsi_1_1.asmx")>= 0) {
linkType = "WaterOneFlow";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wms.axd/") > 0) {
linkType = "WMS";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wmts.axd/") > 0) {
linkType = "WMTS";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wfs.axd/") > 0) {
linkType = "WFS";
linkUrl = url;
}
}
}
if (linkType !== null && (isHttp || isFtp)) {
return {linkType:linkType,linkUrl:linkUrl};
Expand Down
96 changes: 0 additions & 96 deletions geoportal/src/main/resources/metadata/js/EvaluatorFor_ISO.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,104 +185,8 @@ G.evaluators.iso = {
G.evalProps(task,item,root,"apiso_CouplingType_s","//gmd:identificationInfo/srv:SV_ServiceIdentification/srv:couplingType/srv:SV_CouplingType/@codeListValue");

G.evalResourceLinks(task,item,root,"//gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL | //gmd:identificationInfo/srv:SV_ServiceIdentification/srv:containsOperations/srv:SV_OperationMetadata/srv:connectPoint/gmd:CI_OnlineResource/gmd:linkage/gmd:URL");
this.evalResourceLinks(task, item, root, "//gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL | //gmd:identificationInfo/srv:SV_ServiceIdentification/srv:containsOperations/srv:SV_OperationMetadata/srv:connectPoint/gmd:CI_OnlineResource/gmd:linkage/gmd:URL");
},

evalResourceLinks: function(task,obj,contextNode,xpathExpression) {
if (!contextNode) return;
var self = this, urls = [], name = "resources_nst";
G.forEachNode(task,contextNode,xpathExpression,function(node){
var url = G.getNodeText(node);
var info = self.checkResourceLink(url);
if (info && info.linkUrl && info.linkType) {
if (urls.indexOf(info.linkUrl) === -1) {
urls.push(info.linkUrl);
G.writeMultiProp(obj,name,{
"url_s": info.linkUrl,
"url_type_s": info.linkType
});
}
}
});
},
checkResourceLink: function(url) {
var endsWith = function(v,sfx) {return (v.indexOf(sfx,(v.length-sfx.length)) !== -1);};

var arcgisTypes = ["MapServer","ImageServer","FeatureServer","GlobeServer","GPServer","GeocodeServer",
"GeometryServer","NAServer","GeoDataServer ","MobileServer","SceneServer",
"SchematicsServer","StreamServer","VectorTileServer"];
var ogcTypes = ["WMS","WFS","WCS","WMTS","WPS","SOS","CSW"];
var dataTypes = ["zip","shp"];

var i, v, lc, linkType = null, linkUrl = null;
var isHttp = (typeof url === "string" && (url.indexOf("http://") === 0 || url.indexOf("https://") === 0));
var isFtp = (typeof url === "string" && (url.indexOf("ftp://") === 0 || url.indexOf("ftps://") === 0));
if (isHttp) {
lc = url.toLowerCase();
if (lc.indexOf("service=") > 0) {
//if (lc.indexOf("request=getcapabilities") > 0) {}
for (i=0;i<ogcTypes.length;i++) {
v = "service="+ogcTypes[i].toLowerCase();
if (lc.indexOf("?"+v) > 0 || lc.indexOf("&"+v) > 0) {
linkType = ogcTypes[i];
linkUrl = url;
break;
}
}
} else if (lc.indexOf("/rest/services/") > 0) {
for (i=0;i<arcgisTypes.length;i++) {
v = "/"+arcgisTypes[i].toLowerCase();
if (endsWith(lc,v)) {
linkType = arcgisTypes[i];
linkUrl = url;
break;
}
}
}
if (linkType === null) {
if (endsWith(lc,".kml") || endsWith(lc,".kmz") ||
lc.indexOf("?f=kml") > 0 || lc.indexOf("&f=kml") > 0 ||
lc.indexOf("?f=kmz") > 0 || lc.indexOf("&f=kmz") > 0) {
linkType = "kml";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("com.esri.wms.esrimap")>= 0) {
linkType = "IMS";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("cuahsi_1_1.asmx")>= 0) {
linkType = "WaterOneFlow";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wms.axd/") > 0) {
linkType = "WMS";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wmts.axd/") > 0) {
linkType = "WMTS";
linkUrl = url;
}
}
if (linkType === null) {
if (lc.indexOf("/wfs.axd/") > 0) {
linkType = "WFS";
linkUrl = url;
}
}
}
if (linkType !== null && (isHttp || isFtp)) {
return {linkType:linkType,linkUrl:linkUrl};
}
},

evalSpatial: function(task) {
var item = task.item, root = task.root;
var hasEnvelope = false;
Expand Down
16 changes: 16 additions & 0 deletions geoportal/src/main/resources/metadata/xslt/identity.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Document : identity.xsl
Created on : December 13, 2023
Author : Marten
Description: Perform identity transform on the metadata.
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
{
"rel": "items",
"type": "application/json",
"type": "application/geo+json",
"title": "Items in this collection",
"href": "{url}/collections/{collectionId}/items",
"hreflang": "en-US"
Expand Down
125 changes: 65 additions & 60 deletions geoportal/src/main/resources/service/config/stac-itemLinks.json
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
{
"metadataItem":
{
"links": [
{
"rel": "self",
"type": "application/json",
"title": "Link to all collections",
"href": "{url}/collections/metadata/items",
"hreflang": "en-US"
},
{
"rel": "next",
"type": "application/json",
"title": "Next page of results",
"href": "{url}/collections/metadata/items?{urlparam}",
"hreflang": "en-US"
},
{
"rel": "parent",
"type": "application/json",
"title": "Link to the Metadata collection",
"href": "{url}/collections/metadata",
"hreflang": "en-US"
},
{
"rel": "root",
"type": "application/json",
"title": "Link to all collections",
"href": "{url}",
"hreflang": "en-US"
}
]
},
"searchItem":
{
"links": [
{
"rel": "self",
"type": "application/json",
"title": "Next page of results",
"href": "{url}/search",
"hreflang": "en-US"
},
{
"rel": "next",
"type": "application/json",
"title": "Next page of results",
"href": "{url}/search?{urlparam}",
"hreflang": "en-US"
},
{
"rel": "root",
"type": "application/json",
"title": "Link to all collections",
"href": "{url}",
"hreflang": "en-US"
}
]
}
}
"metadataItem": {
"links": [
{
"rel": "self",
"type": "application/geo+json",
"title": "Link to all collections",
"href": "{url}/collections/metadata/items",
"hreflang": "en-US"
},
{
"rel": "next",
"type": "application/geo+json",
"title": "Next page of results",
"href": "{url}/collections/metadata/items?{urlparam}",
"hreflang": "en-US"
},
{
"rel": "previous",
"type": "application/geo+json",
"title": "Next page of results",
"href": "{url}/collections/metadata/items?{urlparam}",
"hreflang": "en-US"
},
{
"rel": "parent",
"type": "application/json",
"title": "Link to the Metadata collection",
"href": "{url}/collections/metadata",
"hreflang": "en-US"
},
{
"rel": "root",
"type": "application/json",
"title": "Link to all collections",
"href": "{url}",
"hreflang": "en-US"
}
]
},
"searchItem": {
"links": [
{
"rel": "self",
"type": "application/geo+json",
"title": "Next page of results",
"href": "{url}/search",
"hreflang": "en-US"
},
{
"rel": "next",
"type": "application/geo+json",
"title": "Next page of results",
"href": "{url}/search?{urlparam}",
"hreflang": "en-US"
},
{
"rel": "root",
"type": "application/json",
"title": "Link to all collections",
"href": "{url}",
"hreflang": "en-US"
}
]
}
}

0 comments on commit 3c6e4fa

Please sign in to comment.