From 23353cb9bde46fb46e9a8214b960662091b97476 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Fri, 23 Sep 2016 15:46:35 +0200 Subject: [PATCH 01/20] bump to 1.6.4 Signed-off-by: Emmanuel Mathot --- Terradue.OpenSearch.Client/Properties/AssemblyInfo.cs | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Terradue.OpenSearch.Client/Properties/AssemblyInfo.cs b/Terradue.OpenSearch.Client/Properties/AssemblyInfo.cs index 1a41e54d..c7d989a9 100644 --- a/Terradue.OpenSearch.Client/Properties/AssemblyInfo.cs +++ b/Terradue.OpenSearch.Client/Properties/AssemblyInfo.cs @@ -14,8 +14,8 @@ // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("1.6.3.*")] -[assembly: AssemblyInformationalVersion("1.6.3")] +[assembly: AssemblyVersion("1.6.4.*")] +[assembly: AssemblyInformationalVersion("1.6.4")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. //[assembly: AssemblyDelaySign(false)] diff --git a/pom.xml b/pom.xml index 0a41a340..8c31e609 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ opensearch-client rpm OpenSearch Client - 1.6.3 + 1.6.4-SNAPSHOT opensearch-client From 41b21ac4946de8ca4a6e8d2ac2192f28c504f09a Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Mon, 17 Oct 2016 12:27:31 +0200 Subject: [PATCH 02/20] more fixes Signed-off-by: Emmanuel Mathot --- .../Terradue.OpenSearch.Model.Base.csproj | 10 + .../EarthObservationDataModelExtension.cs | 16 +- .../OpenSearchable/CwicOpenSearchable.cs | 200 +++++++---- .../OpenSearchable/FedeoOpenSearchable.cs | 2 +- .../Sentinel1QcOpenSearchRequest.cs | 316 ++++++++++++++++++ .../Sentinel1Qc/Sentinel1QcOpenSearchable.cs | 158 +++++++++ .../packages.config | 3 +- 7 files changed, 632 insertions(+), 73 deletions(-) create mode 100644 Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchRequest.cs create mode 100644 Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchable.cs diff --git a/Terradue.OpenSearch.Model.Base/Terradue.OpenSearch.Model.Base.csproj b/Terradue.OpenSearch.Model.Base/Terradue.OpenSearch.Model.Base.csproj index 894c57ec..a1cfdd40 100644 --- a/Terradue.OpenSearch.Model.Base/Terradue.OpenSearch.Model.Base.csproj +++ b/Terradue.OpenSearch.Model.Base/Terradue.OpenSearch.Model.Base.csproj @@ -91,12 +91,19 @@ ..\packages\Terradue.Metadata.EarthObservation.1.4.12\lib\net40\Terradue.Metadata.EarthObservation.dll + ..\packages\Terradue.OpenSearch.SciHub.1.2.1\lib\net40\Terradue.OpenSearch.SciHub.dll ..\packages\Terradue.OpenSearch.1.13.0\lib\net40\Terradue.OpenSearch.dll + + ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net40\HtmlAgilityPack.dll + + + ..\packages\Terradue.OpenSearch.SciHub.1.2.2\lib\net40\Terradue.OpenSearch.SciHub.dll + @@ -135,6 +142,8 @@ + + @@ -144,6 +153,7 @@ + diff --git a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/EarthObservationDataModelExtension.cs b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/EarthObservationDataModelExtension.cs index f1dd9d78..147fdd02 100644 --- a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/EarthObservationDataModelExtension.cs +++ b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/EarthObservationDataModelExtension.cs @@ -74,12 +74,21 @@ public override IOpenSearchable CreateOpenSearchable(List baseUrls, string } foreach (var url in baseUrls) { - var e = OpenSearchFactory.FindOpenSearchable(ose, url, ext.DiscoveryContentType); + IOpenSearchable e = null; + // QC Sentinel1 case + if (url.Host == "qc.sentinel1.eo.esa.int") + { + log.DebugFormat("QC Sentinel1 source. Trying to get the earthobservation profile"); + e = new Sentinel1QcOpenSearchable(url, ose); + entities.Add(e); + continue; + } + e = OpenSearchFactory.FindOpenSearchable(ose, url, ext.DiscoveryContentType, lax); if (!e.DefaultMimeType.Contains("profile=http://earth.esa.int/eop")) { try { - e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml; profile=http://earth.esa.int/eop/2.1"); + e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml; profile=http://earth.esa.int/eop/2.1", lax); } catch (InvalidOperationException){ - e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml"); + e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml", lax); } if (!e.DefaultMimeType.Contains("xml")) throw new InvalidOperationException("No Url in the OpenSearch Description Document that could fit the EOP data model"); @@ -94,6 +103,7 @@ public override IOpenSearchable CreateOpenSearchable(List baseUrls, string log.DebugFormat("Cwic source. Trying to get the earthobservation profile"); e = CwicOpenSearchable.CreateFrom((Terradue.OpenSearch.GenericOpenSearchable)e, ose); } + entities.Add(e); } diff --git a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/CwicOpenSearchable.cs b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/CwicOpenSearchable.cs index 9a1c65f3..956a9fc5 100644 --- a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/CwicOpenSearchable.cs +++ b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/CwicOpenSearchable.cs @@ -18,22 +18,27 @@ using Terradue.ServiceModel.Ogc.OwsContext; using Terradue.ServiceModel.Ogc; -namespace Terradue.OpenSearch.Model.EarthObservation.OpenSearchable { - - public class CwicOpenSearchable : GenericOpenSearchable, IOpenSearchable { +namespace Terradue.OpenSearch.Model.EarthObservation.OpenSearchable +{ + + public class CwicOpenSearchable : SoftGenericOpenSearchable, IOpenSearchable + { XmlSerializer eeSer = new XmlSerializer(typeof(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene)); private static readonly ILog log = LogManager.GetLogger(typeof(CwicOpenSearchable)); - public CwicOpenSearchable(OpenSearchDescription osd, OpenSearchEngine ose) : base(osd, ose) { + public CwicOpenSearchable(OpenSearchDescription osd, OpenSearchEngine ose) : base(osd, ose) + { } - public static CwicOpenSearchable CreateFrom(GenericOpenSearchable e, OpenSearchEngine ose) { + public static CwicOpenSearchable CreateFrom(GenericOpenSearchable e, OpenSearchEngine ose) + { return new CwicOpenSearchable(e.GetOpenSearchDescription(), ose); } - public new void ApplyResultFilters(OpenSearchRequest request, ref IOpenSearchResultCollection osr, string finalContentType) { + public new void ApplyResultFilters(OpenSearchRequest request, ref IOpenSearchResultCollection osr, string finalContentType) + { log.DebugFormat("Applying Cwic source harvesting"); base.ApplyResultFilters(request, ref osr, finalContentType); @@ -42,59 +47,91 @@ public static CwicOpenSearchable CreateFrom(GenericOpenSearchable e, OpenSearchE } - private void QueryEarthObservationResult(ref IOpenSearchResultCollection osr) { + private void QueryEarthObservationResult(ref IOpenSearchResultCollection osr) + { - foreach (var item in osr.Items) { + foreach (var item in osr.Items) + { log.DebugFormat("Searching for alternate link to metadata URL for item {0}", item.Identifier); - var altlink = item.Links.FirstOrDefault(l => l.RelationshipType == "alternate" && l.Title == "Alternate metadata URL"); + var altlink = item.Links.FirstOrDefault(l => l.RelationshipType == "via" && l.Title == "Original source metadata"); + + string identifier = null; - if (altlink != null) { + if (altlink != null) + { log.DebugFormat("Link found at {0}", altlink.Uri); var req = HttpWebRequest.Create(altlink.Uri); log.DebugFormat("Query {0}...", altlink.Uri); var response = req.GetResponse(); - var xr = XmlReader.Create(response.GetResponseStream()); - while (xr.Read()) { - if (xr.LocalName == "scene" && xr.NamespaceURI == "http://earthexplorer.usgs.gov/eemetadata.xsd") { - log.DebugFormat("Found scene metadata, harvesting {0} ...", altlink.Uri); - Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene eescene = (Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene)eeSer.Deserialize(xr); - Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo = EarthExplorerToEo(eescene); - AddIMGOffering(eo, item); - if (eo != null) { - log.DebugFormat("EOP extension created from {0}", altlink.Uri); - MemoryStream stream = new MemoryStream(); - XmlWriter writer = XmlWriter.Create(stream); - var ser = OgcHelpers.GetXmlSerializerFromType(eo.GetType()); - ser.Serialize(stream, eo); - writer.Flush(); - stream.Seek(0, SeekOrigin.Begin); - - item.ElementExtensions.Add(XmlReader.Create(stream)); + using (var xr = XmlReader.Create(response.GetResponseStream())) + { + while (xr.Read()) + { + if (xr.LocalName == "scene" && xr.NamespaceURI == "http://earthexplorer.usgs.gov/eemetadata.xsd") + { + log.DebugFormat("Found scene metadata, harvesting {0} ...", altlink.Uri); + Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene eescene = (Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene)eeSer.Deserialize(xr); + Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo = EarthExplorerToEo(eescene); + AddIMGOffering(eo, item); + if (eo != null) + { + log.DebugFormat("EOP extension created from {0}", altlink.Uri); + using (MemoryStream stream = new MemoryStream()) + { + XmlWriter writer = XmlWriter.Create(stream); + var ser = OgcHelpers.GetXmlSerializerFromType(eo.GetType()); + ser.Serialize(stream, eo); + writer.Flush(); + stream.Seek(0, SeekOrigin.Begin); + + item.ElementExtensions.Add(XmlReader.Create(stream)); + } + identifier = eo.EopMetaDataProperty.EarthObservationMetaData.identifier; + item.Title = new ServiceModel.Syndication.TextSyndicationContent( + string.Format("{0}, {1}, Path: {2}, Row: {3}", + identifier, + DateTime.Parse(eo.phenomenonTime.GmlTimePeriod.beginPosition.Value).ToString("yy-MMM-dd hh:mm:ss"), + eo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.wrsLongitudeGrid.Value, + eo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.wrsLatitudeGrid.Value + )); + } + continue; } - continue; } - + } } - var identifierext = item.ElementExtensions.FirstOrDefault(e => e.OuterName == "identifier" && e.OuterNamespace == "http://purl.org/dc/elements/1.1/"); - string identifier = identifierext.GetObject().Replace("http://cwic.wgiss.ceos.org/opensearch/granules.atom?uid=", ""); + var identifierext = item.ElementExtensions.FirstOrDefault(e => e.OuterName == "identifier" && e.OuterNamespace == "http://purl.org/dc/elements/1.1/"); + if (identifier == null) + { + UriBuilder url = new UriBuilder(identifierext.GetObject()); + NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(url.Query); + identifier = nvc["uid"]; + if (identifier.Contains(":")) + identifier = identifier.Split(':')[1]; + + } item.ElementExtensions.Remove(identifierext); item.ElementExtensions.Add("identifier", "http://purl.org/dc/elements/1.1/", identifier); } } - private static void AddIMGOffering(Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo, IOpenSearchResultItem item) { + private static void AddIMGOffering(Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo, IOpenSearchResultItem item) + { Terradue.ServiceModel.Ogc.Eop21.BrowseInformationPropertyType[] bi = null; - if (eo.result != null && eo.result.Eop21EarthObservationResult.browse != null) { + if (eo.result != null && eo.result.Eop21EarthObservationResult.browse != null) + { bi = eo.result.Eop21EarthObservationResult.browse; } - if (bi != null) { - foreach (var browse in bi) { + if (bi != null) + { + foreach (var browse in bi) + { if (browse.BrowseInformation.type != "img") continue; @@ -111,13 +148,16 @@ private static void AddIMGOffering(Terradue.ServiceModel.Ogc.Eop21.EarthObservat } } - public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType EarthExplorerToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) { + public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType EarthExplorerToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) + { - if (scene.metadataFields.FirstOrDefault(m => m.name == "Landsat Scene Identifier") != null) { + if (scene.metadataFields.FirstOrDefault(m => m.name == "Landsat Scene Identifier") != null) + { return LandsatToEo(scene); } - if (scene.metadataFields.FirstOrDefault(m => m.name == "Entity ID" && m.metadataValue.StartsWith("SRTM")) != null) { + if (scene.metadataFields.FirstOrDefault(m => m.name == "Entity ID" && m.metadataValue.StartsWith("SRTM")) != null) + { return SRTMToEo(scene); } @@ -125,7 +165,8 @@ public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType EarthExplorer } - public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) { + public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) + { Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType optEo = new Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType(); @@ -144,16 +185,17 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.procedure.Eop21EarthObservationEquipment.platform.Platform.orbitType = Terradue.ServiceModel.Ogc.Eop21.OrbitTypeValueType.LEO; optEo.procedure.Eop21EarthObservationEquipment.instrument = new Terradue.ServiceModel.Ogc.Eop21.InstrumentPropertyType(); optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument = new Terradue.ServiceModel.Ogc.Eop21.InstrumentType(); - switch (identifier.metadataValue.Substring(1, 1)) { - case "T": + switch (identifier.metadataValue.Substring(1, 1)) + { + case "T": optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.shortName = "TIRS"; optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.description = "Thermal Infrared Sensor"; break; - case "O": + case "O": optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.shortName = "OLI"; optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.description = "Operational Land Imager"; break; - case "C": + case "C": optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.shortName = "OLI_TIRS"; optEo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.description = "Operational Land Imager & Thermal Infrared Sensor"; break; @@ -165,7 +207,8 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters = new Terradue.ServiceModel.Ogc.Eop21.AcquisitionPropertyType(); optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition = new Terradue.ServiceModel.Ogc.Eop21.AcquisitionType(); var swrsRow = scene.metadataFields.FirstOrDefault(m => m.name == "Target WRS Row"); - if (swrsRow != null) { + if (swrsRow != null) + { int wrsRow = int.Parse(swrsRow.metadataValue); if (wrsRow > 1 && wrsRow <= 122) optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.orbitDirection = Terradue.ServiceModel.Ogc.Eop21.OrbitDirectionValueType.DESCENDING; @@ -178,13 +221,15 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.wrsLatitudeGrid.Value = wrsRow.ToString(); } var swrsPath = scene.metadataFields.FirstOrDefault(m => m.name == "Target WRS Path"); - if (swrsPath != null) { + if (swrsPath != null) + { optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.wrsLongitudeGrid = new Terradue.ServiceModel.Ogc.Gml321.CodeWithAuthorityType(); optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.wrsLongitudeGrid.Value = swrsPath.metadataValue.Trim(); } var fullscene = scene.metadataFields.FirstOrDefault(m => m.name == "Full or Partial Scene"); - if (fullscene != null) { + if (fullscene != null) + { Terradue.ServiceModel.Ogc.Eop21.SpecificInformationPropertyType vss = new Terradue.ServiceModel.Ogc.Eop21.SpecificInformationPropertyType(); vss.SpecificInformation = new Terradue.ServiceModel.Ogc.Eop21.SpecificInformationType(); vss.SpecificInformation.localAttribute = "full_partial_scene"; @@ -192,8 +237,10 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE } var dataCat = scene.metadataFields.FirstOrDefault(m => m.name == "Data Category"); - if (dataCat != null) { - switch (dataCat.metadataValue) { + if (dataCat != null) + { + switch (dataCat.metadataValue) + { case "NOMINAL": optEo.EopMetaDataProperty.EarthObservationMetaData.acquisitionType = Terradue.ServiceModel.Ogc.Eop21.AcquisitionTypeValueType.NOMINAL; break; @@ -217,7 +264,8 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation = new Terradue.ServiceModel.Ogc.Eop21.ProcessingInformationType(); var level1 = scene.metadataFields.FirstOrDefault(m => m.name == "Data Type Level 1"); - if (level1 != null) { + if (level1 != null) + { optEo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation.processingLevel = level1.metadataValue; } @@ -226,19 +274,23 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE List aux = new List(); var bpfoli = scene.metadataFields.FirstOrDefault(m => m.name == "Bias Parameter File Name OLI"); - if (bpfoli != null) { + if (bpfoli != null) + { aux.Add(bpfoli.metadataValue); } var bpftirs = scene.metadataFields.FirstOrDefault(m => m.name == "Bias Parameter File Name TIRS"); - if (bpftirs != null) { + if (bpftirs != null) + { aux.Add(bpftirs.metadataValue); } var bpfcal = scene.metadataFields.FirstOrDefault(m => m.name == "Calibration Parameter File"); - if (bpfcal != null) { + if (bpfcal != null) + { aux.Add(bpfcal.metadataValue); } var bpfrlut = scene.metadataFields.FirstOrDefault(m => m.name == "RLUT File Name"); - if (bpfrlut != null) { + if (bpfrlut != null) + { aux.Add(bpfrlut.metadataValue); } @@ -248,12 +300,14 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.phenomenonTime.GmlTimePeriod = new Terradue.ServiceModel.Ogc.Gml321.TimePeriodType(); var start = scene.metadataFields.FirstOrDefault(m => m.name == "Start Time"); var stop = scene.metadataFields.FirstOrDefault(m => m.name == "Stop Time"); - if (start != null) { + if (start != null) + { DateTime startdate = ParseDateTime(start.metadataValue); optEo.phenomenonTime.GmlTimePeriod.beginPosition = new Terradue.ServiceModel.Ogc.Gml321.TimePositionType(); optEo.phenomenonTime.GmlTimePeriod.beginPosition.Value = startdate.ToString("O"); } - if (stop != null) { + if (stop != null) + { DateTime stopdate = ParseDateTime(stop.metadataValue); optEo.phenomenonTime.GmlTimePeriod.endPosition = new Terradue.ServiceModel.Ogc.Gml321.TimePositionType(); optEo.phenomenonTime.GmlTimePeriod.endPosition.Value = stopdate.ToString("O"); @@ -262,7 +316,8 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE optEo.EopMetaDataProperty.EarthObservationMetaData.vendorSpecific = vs.ToArray(); var qua = scene.metadataFields.FirstOrDefault(m => m.name == "Image Quality"); - if (qua != null) { + if (qua != null) + { optEo.EopMetaDataProperty.EarthObservationMetaData.imageQualityDegradation = new Terradue.ServiceModel.Ogc.Gml321.MeasureType(); optEo.EopMetaDataProperty.EarthObservationMetaData.imageQualityDegradation.Value = double.Parse(qua.metadataValue); } @@ -273,35 +328,42 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE var cc = scene.metadataFields.FirstOrDefault(m => m.name == "Scene Cloud Cover"); double ccd; - if (cc != null && double.TryParse(cc.metadataValue, out ccd)) { + if (cc != null && double.TryParse(cc.metadataValue, out ccd)) + { optEo.result.Opt21EarthObservationResult.cloudCoverPercentage = new Terradue.ServiceModel.Ogc.Gml321.MeasureType(); optEo.result.Opt21EarthObservationResult.cloudCoverPercentage.Value = ccd; } var sunelev = scene.metadataFields.FirstOrDefault(m => m.name == "Sun Elevation"); - if (sunelev != null) { + if (sunelev != null) + { optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.illuminationElevationAngle = new Terradue.ServiceModel.Ogc.Gml321.AngleType(); optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.illuminationElevationAngle.Value = double.Parse(sunelev.metadataValue); } var sunazimuth = scene.metadataFields.FirstOrDefault(m => m.name == "Sun Azimuth"); - if (sunazimuth != null) { + if (sunazimuth != null) + { optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.illuminationAzimuthAngle = new Terradue.ServiceModel.Ogc.Gml321.AngleType(); optEo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.Acquisition.illuminationAzimuthAngle.Value = double.Parse(sunazimuth.metadataValue); } var brwexist = scene.metadataFields.FirstOrDefault(m => m.name == "Browse Exists"); - if (brwexist != null && brwexist.metadataValue == "Y") { + if (brwexist != null && brwexist.metadataValue == "Y") + { - if (scene.overlayLinks.Count() > 0) { + if (scene.overlayLinks.Count() > 0) + { var overlay = scene.overlayLinks.FirstOrDefault(l => l.caption.Contains("Natural")); - if (overlay != null) { + if (overlay != null) + { optEo.result.Opt21EarthObservationResult.browse = new Terradue.ServiceModel.Ogc.Eop21.BrowseInformationPropertyType[1]; optEo.result.Opt21EarthObservationResult.browse[0] = new Terradue.ServiceModel.Ogc.Eop21.BrowseInformationPropertyType(); optEo.result.Opt21EarthObservationResult.browse[0].BrowseInformation = new Terradue.ServiceModel.Ogc.Eop21.BrowseInformationType(); var wmsparams = overlay.overlayLink.Split('&'); - if (wmsparams.Count() > 0 && wmsparams.FirstOrDefault(p => p.StartsWith("srs=")) != null) { + if (wmsparams.Count() > 0 && wmsparams.FirstOrDefault(p => p.StartsWith("srs=")) != null) + { optEo.result.Opt21EarthObservationResult.browse[0].BrowseInformation.referenceSystemIdentifier = new Terradue.ServiceModel.Ogc.Gml321.CodeWithAuthorityType(); optEo.result.Opt21EarthObservationResult.browse[0].BrowseInformation.referenceSystemIdentifier.Value = wmsparams.FirstOrDefault(p => p.StartsWith("srs=")).Split('=')[1]; } @@ -316,26 +378,28 @@ public static Terradue.ServiceModel.Ogc.Opt21.OptEarthObservationType LandsatToE } return optEo; - + } - public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType SRTMToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) { + public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType SRTMToEo(Terradue.OpenSearch.Model.Schemas.EarthExplorer.scene scene) + { throw new NotImplementedException(); } - private static DateTime ParseDateTime(string date) { + private static DateTime ParseDateTime(string date) + { var dateelem = date.Split(':'); DateTime doy = DateTime.Parse("2000-01-01T00:00:00"); - doy = doy.AddDays(double.Parse(dateelem[1])-1); + doy = doy.AddDays(double.Parse(dateelem[1]) - 1); var sec = dateelem[4].Split('.'); double div = 100.0 / double.Parse(new StringBuilder("1").Append('0', sec[1].Length - 1).ToString()); double milli = double.Parse(sec[1]) * div; - return new DateTime(int.Parse(dateelem[0]), doy.Month, doy.Day, int.Parse(dateelem[2]), int.Parse(dateelem[3]), int.Parse(sec[0]), (int)milli, DateTimeKind.Utc); + return new DateTime(int.Parse(dateelem[0]), doy.Month, doy.Day, int.Parse(dateelem[2]), int.Parse(dateelem[3]), int.Parse(sec[0]), (int)milli, DateTimeKind.Utc); } } diff --git a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/FedeoOpenSearchable.cs b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/FedeoOpenSearchable.cs index b505d5db..7d911450 100644 --- a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/FedeoOpenSearchable.cs +++ b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/FedeoOpenSearchable.cs @@ -18,7 +18,7 @@ namespace Terradue.OpenSearch.Model.EarthObservation.OpenSearchable public class FedeoOpenSearchable : GenericOpenSearchable, IOpenSearchable { - private static readonly ILog log = LogManager.GetLogger(typeof(CwicOpenSearchable)); + private static readonly ILog log = LogManager.GetLogger(typeof(FedeoOpenSearchable)); public FedeoOpenSearchable(OpenSearchUrl url, OpenSearchEngine ose): base(url, ose){ } diff --git a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchRequest.cs b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchRequest.cs new file mode 100644 index 00000000..b3827da1 --- /dev/null +++ b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchRequest.cs @@ -0,0 +1,316 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Text.RegularExpressions; +using System.Web; +using System.Xml; +using System.Xml.Serialization; +using HtmlAgilityPack; +using log4net; +using Terradue.OpenSearch.Request; +using Terradue.OpenSearch.Response; +using Terradue.OpenSearch.Result; +using Terradue.ServiceModel.Ogc; +using Terradue.ServiceModel.Syndication; + +namespace Terradue.OpenSearch.Model.EarthObservation.OpenSearchable +{ + class Sentinel1QcOpenSearchRequest : OpenSearchRequest + { + OpenSearchUrl openSearchUrl; + NameValueCollection parameters; + readonly Uri qcSearchUrl; + + XmlSerializer eeser = new XmlSerializer(typeof(Terradue.OpenSearch.SciHub.Data.Earth_Explorer_File)); + + private static readonly ILog log = LogManager.GetLogger(typeof(Sentinel1QcOpenSearchRequest)); + + Uri qcBaseUrl; + + + public Sentinel1QcOpenSearchRequest(Uri qcSearchUrl, NameValueCollection parameters) : base(new OpenSearchUrl(qcSearchUrl), "application/atom+xml") + { + this.qcSearchUrl = qcSearchUrl; + var tmpurl = new UriBuilder(qcSearchUrl); + tmpurl.Path = ""; + tmpurl.Query = ""; + this.qcBaseUrl = tmpurl.Uri; + this.parameters = parameters; + } + + public override NameValueCollection OriginalParameters + { + get + { + return parameters; + } + + set + { + parameters = value; + } + } + + public override IOpenSearchResponse GetResponse() + { + + Stopwatch sw = new Stopwatch(); + sw.Start(); + + AtomFeed feed = new AtomFeed(); + + int count = string.IsNullOrEmpty(parameters["count"]) ? 20 : int.Parse(parameters["count"]); + int page = string.IsNullOrEmpty(parameters["startPage"]) ? 1 : int.Parse(parameters["startPage"]); + int index = string.IsNullOrEmpty(parameters["startIndex"]) ? 1 : int.Parse(parameters["startIndex"]); + string type = string.IsNullOrEmpty(parameters["auxtype"]) ? "aux_resorb" : parameters["auxtype"]; + bool withOrbits = parameters["orbits"] == "true"; + + int absindex = index + ((page - 1) * count); + int queryindex = absindex % 20; + int querypage = (absindex / 20) + 1; + + List items = new List(); + + while (items.Count() < count) + { + + Uri url = BuildUrl(qcBaseUrl, count, index, page, type, parameters["start"], parameters["stop"]); + + var request = HttpWebRequest.Create(url); + + log.DebugFormat("Query: {0}", url); + + HtmlDocument doc = new HtmlDocument(); + + using (var response = request.GetResponse()) + { + doc.Load(response.GetResponseStream()); + } + + Dictionary list = new Dictionary(); + + var pagesli = doc.DocumentNode.SelectNodes("/html/body/div/div/div/div[1]/div/ul/li"); + int lastpage = 1; + + if (pagesli != null) + { + lastpage = pagesli.Max(li => + { + int pageo = 0; + if (int.TryParse(li.FirstChild.InnerText, out pageo)) + return pageo; + return 0; + }); + } + + if (lastpage < querypage) + break; + + var trs = doc.DocumentNode.SelectNodes("/html/body/div/div/div/div[1]/table/tbody/tr"); + + if (trs == null) + break; + + foreach (HtmlNode tr in trs) + { + var a = tr.SelectSingleNode("td/a"); + log.Debug(a.InnerText); + HtmlAttribute href = a.Attributes["href"]; + var producturl = new Uri(string.Format("{0}/{1}/{2}", qcBaseUrl, type, href.Value)); + log.Debug(producturl); + list.Add(a.InnerText, producturl); + } + + if (list.Count() == 0) + break; + + if (items.FirstOrDefault(i => i.Identifier == list.Last().Key.Replace(".EOF", "")) != null) + break; + + items.AddRange(BuildAtomItem(list.Skip(queryindex - 1).Take(count - items.Count()), withOrbits)); + + queryindex = 1; + page++; + + } + + feed.Items = items; + + sw.Stop(); + + return new Terradue.OpenSearch.Response.AtomOpenSearchResponse(feed, sw.Elapsed); + } + + IEnumerable BuildAtomItem(IEnumerable> products, bool withOrbits) + { + List items = new List(); + + foreach (var product in products) + { + var item = CreateItemFromLink(product.Key, product.Value, withOrbits); + if (item != null) + items.Add(item); + } + + return items; + } + + AtomItem CreateItemFromLink(string key, Uri url, bool withOrbits) + { + string identifier = key.Replace(".EOF", ""); + Match match = Regex.Match(identifier, + @"^(?'mission'\w{3})_OPER_AUX_(?'type'\w{6})_(?'system'\w{4})_(?'proddate'\w{15})_V(?'startdate'\w{15})_(?'stopdate'\w{15})$"); + + if (!match.Success) + return null; + + AtomItem item = new AtomItem(identifier, string.Format("{0} {1} {2} {3}", match.Groups["mission"].Value, + match.Groups["type"].Value, + match.Groups["startdate"].Value, + match.Groups["stopdate"].Value), + url, + identifier, + DateTimeOffset.ParseExact(match.Groups["proddate"].Value, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture).ToUniversalTime()); + + DateTime start = DateTime.ParseExact(match.Groups["startdate"].Value, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture).ToUniversalTime(); + DateTime stop = DateTime.ParseExact(match.Groups["stopdate"].Value, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture).ToUniversalTime(); + + item.Identifier = identifier; + item.PublishDate = DateTimeOffset.ParseExact(match.Groups["proddate"].Value, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture).ToUniversalTime(); + item.Links.Add(SyndicationLink.CreateMediaEnclosureLink(url, "application/xml", 0)); + item.ElementExtensions.Add("polygon", "http://www.georss.org/georss", "-90 -180 -90 180 90 180 90 -180 -90 -180"); + item.ElementExtensions.Add("date", "http://purl.org/dc/elements/1.1/", string.Format("{0}/{1}", start.ToString("O"), stop.ToString("O"))); + + Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo = OrbToEo(identifier, match.Groups["mission"].Value, match.Groups["type"].Value, start, stop, item.PublishDate); + if (eo != null) + { + log.DebugFormat("EOP extension created from {0}", url); + using (MemoryStream stream = new MemoryStream()) + { + XmlWriter writer = XmlWriter.Create(stream); + var ser = OgcHelpers.GetXmlSerializerFromType(eo.GetType()); + ser.Serialize(stream, eo); + writer.Flush(); + stream.Seek(0, SeekOrigin.Begin); + + item.ElementExtensions.Add(XmlReader.Create(stream)); + } + } + + if (withOrbits) + { + + var request = HttpWebRequest.Create(url); + + using (var response = request.GetResponse()) + { + + + Terradue.OpenSearch.SciHub.Data.Earth_Explorer_File eefile = (Terradue.OpenSearch.SciHub.Data.Earth_Explorer_File)eeser.Deserialize(response.GetResponseStream()); + + item.ElementExtensions.Add(GenerateOrbitsExtension(eefile)); + } + } + + return item; + + } + + static Uri BuildUrl(Uri qcSearchUrl, int count, int index, int page, string type, string start, string stop) + { + UriBuilder url = new UriBuilder(qcSearchUrl); + url.Path += string.Format("/{0}/", string.IsNullOrEmpty(type) ? "aux_resorb" : type); + var qs = HttpUtility.ParseQueryString(""); + + int absindex = index + ((page - 1) * count); + int querypage = (absindex / 20) + 1; + + qs.Set("page", querypage.ToString()); + + if (!string.IsNullOrEmpty(start)) + qs.Set("validity_start_time", string.Format("{0}{1}", start, string.IsNullOrEmpty(stop) ? "" : ".." + stop)); + url.Query = qs.ToString(); + + return url.Uri; + + } + + public static Terradue.ServiceModel.Ogc.Eop21.EarthObservationType OrbToEo(string identifier, string mission, string type, DateTime start, DateTime stop, DateTimeOffset published) + { + + Terradue.ServiceModel.Ogc.Eop21.EarthObservationType eo = new Terradue.ServiceModel.Ogc.Eop21.EarthObservationType(); + + eo.EopMetaDataProperty = new Terradue.ServiceModel.Ogc.Eop21.EarthObservationMetaDataPropertyType(); + eo.EopMetaDataProperty.EarthObservationMetaData = new Terradue.ServiceModel.Ogc.Eop21.EarthObservationMetaDataType(); + eo.EopMetaDataProperty.EarthObservationMetaData.identifier = identifier; + + eo.procedure = new Terradue.ServiceModel.Ogc.Om.OM_ProcessPropertyType(); + eo.procedure.Eop21EarthObservationEquipment = new Terradue.ServiceModel.Ogc.Eop21.EarthObservationEquipmentType(); + eo.procedure.Eop21EarthObservationEquipment.platform = new Terradue.ServiceModel.Ogc.Eop21.PlatformPropertyType(); + eo.procedure.Eop21EarthObservationEquipment.platform.Platform = new Terradue.ServiceModel.Ogc.Eop21.PlatformType(); + eo.procedure.Eop21EarthObservationEquipment.platform.Platform.shortName = mission; + eo.procedure.Eop21EarthObservationEquipment.platform.Platform.orbitType = Terradue.ServiceModel.Ogc.Eop21.OrbitTypeValueType.LEO; + eo.EopMetaDataProperty.EarthObservationMetaData.acquisitionType = Terradue.ServiceModel.Ogc.Eop21.AcquisitionTypeValueType.NOMINAL; + eo.EopMetaDataProperty.EarthObservationMetaData.productType = type; + eo.EopMetaDataProperty.EarthObservationMetaData.processing = new Terradue.ServiceModel.Ogc.Eop21.ProcessingInformationPropertyType[1]; + eo.EopMetaDataProperty.EarthObservationMetaData.processing[0] = new Terradue.ServiceModel.Ogc.Eop21.ProcessingInformationPropertyType(); + eo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation = new Terradue.ServiceModel.Ogc.Eop21.ProcessingInformationType(); + eo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation.processingCenter = new ServiceModel.Ogc.Gml321.CodeListType(); + eo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation.processingCenter.Text = "POD"; + eo.EopMetaDataProperty.EarthObservationMetaData.processing[0].ProcessingInformation.processingDate = published.DateTime; + + eo.phenomenonTime = new Terradue.ServiceModel.Ogc.Om.TimeObjectPropertyType(); + eo.phenomenonTime.GmlTimePeriod = new Terradue.ServiceModel.Ogc.Gml321.TimePeriodType(); + if (start != null) + { + eo.phenomenonTime.GmlTimePeriod.beginPosition = new Terradue.ServiceModel.Ogc.Gml321.TimePositionType(); + eo.phenomenonTime.GmlTimePeriod.beginPosition.Value = start.ToString("O"); + } + if (stop != null) + { + eo.phenomenonTime.GmlTimePeriod.endPosition = new Terradue.ServiceModel.Ogc.Gml321.TimePositionType(); + eo.phenomenonTime.GmlTimePeriod.endPosition.Value = stop.ToString("O"); + } + + + + return eo; + + } + + public static SyndicationElementExtension GenerateOrbitsExtension(Terradue.OpenSearch.SciHub.Data.Earth_Explorer_File file) + { + + SyndicationElementExtension extension = new SyndicationElementExtension(GetS1OrbitsFromEE(file), Terradue.Metadata.EarthObservation.Extra.orbitListType.OrbitsSerializer); + + return extension; + } + + + public static Terradue.Metadata.EarthObservation.Extra.orbitListType GetS1OrbitsFromEE(Terradue.OpenSearch.SciHub.Data.Earth_Explorer_File file) + { + + Terradue.Metadata.EarthObservation.Extra.orbitListType orbits = new Terradue.Metadata.EarthObservation.Extra.orbitListType(); + + orbits.orbit = file.Data_Block.List_of_OSVs.OSV. + Select(o => + { + Terradue.Metadata.EarthObservation.Extra.orbitType orbit = new Terradue.Metadata.EarthObservation.Extra.orbitType(); + orbit.time = DateTime.SpecifyKind(DateTime.Parse(o.UTC.Replace("UTC=", "")), DateTimeKind.Utc); + orbit.frame = Terradue.Metadata.EarthObservation.Extra.referenceFrameType.EarthFixed; + orbit.absoluteOrbit = int.Parse(o.Absolute_Orbit.Replace("+", "")); + orbit.position = new double[] { o.X.Value, o.Y.Value, o.Z.Value }; + orbit.velocity = new double[] { o.VX.Value, o.VY.Value, o.VZ.Value }; + return orbit; + }).ToArray(); + + return orbits; + + } + } +} \ No newline at end of file diff --git a/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchable.cs b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchable.cs new file mode 100644 index 00000000..b082498e --- /dev/null +++ b/Terradue.OpenSearch.Model.Base/Terradue/OpenSearch/Model/EarthObservation/OpenSearchable/Sentinel1Qc/Sentinel1QcOpenSearchable.cs @@ -0,0 +1,158 @@ +using System; +using Terradue.OpenSearch.Model.GeoTime; +using Mono.Addins; +using System.Collections.Specialized; +using System.Collections.Generic; +using Terradue.OpenSearch.Engine; +using System.Net; +using Terradue.OpenSearch.Schema; +using Terradue.OpenSearch.Request; +using Terradue.OpenSearch.Result; +using System.Linq; +using System.Xml; +using log4net; +using System.Xml.Serialization; +using Terradue.Metadata.EarthObservation; +using System.IO; +using System.Text; +using Terradue.ServiceModel.Ogc.OwsContext; +using Terradue.ServiceModel.Ogc; +using Terradue.OpenSearch.Engine.Extensions; +using System.Web; + +namespace Terradue.OpenSearch.Model.EarthObservation.OpenSearchable +{ + + public class Sentinel1QcOpenSearchable : IOpenSearchable + { + + + private static readonly ILog log = LogManager.GetLogger(typeof(Sentinel1QcOpenSearchable)); + + public string Identifier + { + get + { + return "qc-sentinel1"; + } + } + + public long TotalResults + { + get + { + return 0; + } + } + + public string DefaultMimeType + { + get + { + return "application/atom+xml"; + } + } + + public bool CanCache + { + get + { + return true; + } + } + + readonly Uri qcBaseUrl; + readonly OpenSearchEngine ose; + + public Sentinel1QcOpenSearchable(Uri qcBaseUrl, OpenSearchEngine ose) + { + this.ose = ose; + this.qcBaseUrl = qcBaseUrl; + } + + public QuerySettings GetQuerySettings(Terradue.OpenSearch.Engine.OpenSearchEngine ose) + { + IOpenSearchEngineExtension osee = new AtomOpenSearchEngineExtension(); + return new QuerySettings(osee.DiscoveryContentType, osee.ReadNative); + } + + public Terradue.OpenSearch.Request.OpenSearchRequest Create(QuerySettings querySettings, System.Collections.Specialized.NameValueCollection parameters) + { + + log.DebugFormat("Create OS QC Sentinel1"); + + UriBuilder url = new UriBuilder(qcBaseUrl); + url.Path += string.Format("/search"); + url.Query = string.Format("type={3}&start={0}&stop={1}&startIndex={2}&ills=true", parameters["start"], parameters["stop"], parameters["startIndex"], + string.IsNullOrEmpty(parameters["auxtype"]) ? "aux_resorb" : parameters["auxtype"]); + + //if (parameters["ills"] == "true") + //{ + return new Sentinel1QcOpenSearchRequest(url.Uri, parameters); + //} + + NameValueCollection illParams = new NameValueCollection(parameters); + illParams.Set("ills", "true"); + + return new IllimitedOpenSearchRequest(ose, this, "application/atom+xml", new OpenSearchUrl(url.Uri), illParams); + } + + public Terradue.OpenSearch.Schema.OpenSearchDescription GetOpenSearchDescription() + { + OpenSearchDescription osd = new OpenSearchDescription(); + osd.ShortName = "SciHub"; + osd.Contact = "info@terradue.com"; + osd.SyndicationRight = "open"; + osd.AdultContent = "false"; + osd.Language = "en-us"; + osd.OutputEncoding = "UTF-8"; + osd.InputEncoding = "UTF-8"; + osd.Developer = "Terradue OpenSearch Development Team"; + osd.Attribution = "Terradue"; + + List urls = new List(); + + UriBuilder urlb = new UriBuilder(qcBaseUrl); + urlb.Path += "/description"; + + OpenSearchDescriptionUrl url = new OpenSearchDescriptionUrl("application/opensearchdescription+xml", urlb.ToString(), "self"); + urls.Add(url); + + urlb = new UriBuilder(qcBaseUrl); + urlb.Path += "/search"; + NameValueCollection query = GetOpenSearchParameters("application/atom+xml"); + + string[] queryString = Array.ConvertAll(query.AllKeys, key => string.Format("{0}={1}", key, query[key])); + urlb.Query = string.Join("&", queryString); + url = new OpenSearchDescriptionUrl("application/atom+xml", urlb.ToString(), "search"); + url.IndexOffset = 0; + urls.Add(url); + + osd.Url = urls.ToArray(); + osd.DefaultUrl = url; + + return osd; + } + + public System.Collections.Specialized.NameValueCollection GetOpenSearchParameters(string mimeType) + { + var osdic = OpenSearchFactory.GetBaseOpenSearchParameter(); + osdic.Add("uid", "{geo:uid?}"); + osdic.Add("start", "{time:start?}"); + osdic.Add("stop", "{time:end?}"); + osdic.Add("ills", "{t2:ills?}"); + osdic.Add("auxtype", "{t2:auxtype?}"); + osdic.Add("orbits", "{t2:orbits?}"); + return osdic; + } + + public void ApplyResultFilters(Terradue.OpenSearch.Request.OpenSearchRequest request, ref Terradue.OpenSearch.Result.IOpenSearchResultCollection osr, string finalContentType) + { + + } + + + } + +} + diff --git a/Terradue.OpenSearch.Model.Base/packages.config b/Terradue.OpenSearch.Model.Base/packages.config index 83543616..62efe84a 100644 --- a/Terradue.OpenSearch.Model.Base/packages.config +++ b/Terradue.OpenSearch.Model.Base/packages.config @@ -1,6 +1,7 @@  + @@ -12,7 +13,7 @@ - + From b946a436f9a3ff63b998f6125245cd087a703c63 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Mon, 17 Oct 2016 12:46:00 +0200 Subject: [PATCH 03/20] e Signed-off-by: Emmanuel Mathot --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c31e609..8d4e5f68 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ /usr/local/lib/ne_110m_land - ${basedir}/packages/Terradue.Metadata.EarthObservation.1.3.13/content/Resources/ne_110m_land + ${basedir}/packages/Terradue.Metadata.EarthObservation.1.4.12/content/Resources/ne_110m_land From 3619052ede2efd831d821dcb1138e20e6f27029f Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 12:58:04 +0200 Subject: [PATCH 04/20] Added structure for the integration tests --- pom.xml | 306 +++++++++++--------- src/test/run_tests.sh | 6 + src/test/test_common.sh | 15 + src/test/tests.d/test_metadata_retrieval.sh | 13 + 4 files changed, 198 insertions(+), 142 deletions(-) create mode 100755 src/test/run_tests.sh create mode 100755 src/test/test_common.sh create mode 100755 src/test/tests.d/test_metadata_retrieval.sh diff --git a/pom.xml b/pom.xml index 8d4e5f68..9b8d5820 100644 --- a/pom.xml +++ b/pom.xml @@ -1,145 +1,167 @@ - 4.0.0 - - - com.terradue - t2-parent - 16 - - - com.terradue.system - opensearch-client - rpm - OpenSearch Client - 1.6.4-SNAPSHOT - - - opensearch-client - - - - - - org.nuiton.jredmine - jredmine-maven-plugin - false - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - nuget - process-resources - - exec - - - nuget - - restore - -NonInteractive - - - - - compile - compile - - exec - - - xbuild - - - - - - maven-assembly-plugin - 2.4 - - - rpm - prepare-package - - single - - - false - - ${basedir}/src/main/assembly/rpm.xml - - ${project.build.directory}/dependencies - false - / - - - - - - - org.codehaus.mojo - rpm-maven-plugin - true - - 2015, Terradue - Terradue 2015 - air - Terradue - ${project.artifactId} - root - root - 755 - 644 - false - - __jar_repack 0 - __os_install_post %{nil} - - - - /usr/bin - 755 - - - ${basedir}/src/main/scripts/opensearch-client - - - - - /usr/lib/opensearch-client - 755 - - - ${project.build.directory}/dependencies/mono - - - - - /usr/local/lib/ne_110m_land - - - ${basedir}/packages/Terradue.Metadata.EarthObservation.1.4.12/content/Resources/ne_110m_land - - - - - - ${project.artifactId} - - - mono >= 3.12 - - noarch - - - - com.terradue - rpmdeploy-maven-plugin - 1.2 - - - + 4.0.0 + + com.terradue + t2-parent + 16 + + com.terradue.system + opensearch-client + rpm + OpenSearch Client + 1.6.4-SNAPSHOT + + opensearch-client + + + + + org.nuiton.jredmine + jredmine-maven-plugin + false + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + nuget + process-resources + + exec + + + nuget + + restore + -NonInteractive + + + + + compile + compile + + exec + + + xbuild + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.3.1 + + + + /bin/bash + + ${basedir}/src/test/run_tests.sh + + + ${project.build.directory}/dependencies/mono + /usr/share/shunit2 + + ${basedir}/src/test/ + + shunit-test + integration-test + + exec + + + + + + maven-assembly-plugin + 2.4 + + + rpm + + prepare-package + + + single + + + false + + ${basedir}/src/main/assembly/rpm.xml + + ${project.build.directory}/dependencies + false + / + + + + + + org.codehaus.mojo + rpm-maven-plugin + true + + 2016, Terradue + Terradue 2016 + air + Terradue + ${project.artifactId} + root + root + 755 + 644 + false + + __jar_repack 0 + __os_install_post %{nil} + + + + /usr/bin + 755 + + + ${basedir}/src/main/scripts/opensearch-client + + + + + /usr/lib/opensearch-client + 755 + + + ${project.build.directory}/dependencies/mono + + + + + /usr/local/lib/ne_110m_land + + + ${basedir}/packages/Terradue.Metadata.EarthObservation.1.4.12/content/Resources/ne_110m_land + + + + + + ${project.artifactId} + + + mono >= 3.12 + + noarch + + + + com.terradue + rpmdeploy-maven-plugin + 1.2 + + + diff --git a/src/test/run_tests.sh b/src/test/run_tests.sh new file mode 100755 index 00000000..b0b4eb22 --- /dev/null +++ b/src/test/run_tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for test in $( ls tests.d/* ) +do + /bin/bash ${test} +done diff --git a/src/test/test_common.sh b/src/test/test_common.sh new file mode 100755 index 00000000..4223138b --- /dev/null +++ b/src/test/test_common.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# function to execute before each test (e.g., to setup the environment) +function setUp() { + + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENSEARCH_CLIENT_PATH} +} + +function opensearch-client() { + + exec mono ${OPENSEARCH_CLIENT_PATH}/OpenSearchClient.exe "$@" +} + +# function to execute after each test (e.g., to clean up the environment) +#function tearDown() {} diff --git a/src/test/tests.d/test_metadata_retrieval.sh b/src/test/tests.d/test_metadata_retrieval.sh new file mode 100755 index 00000000..9b136256 --- /dev/null +++ b/src/test/tests.d/test_metadata_retrieval.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source ./test_common.sh + +reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" + +test_wkt() +{ + local output=$( opensearch-client "${reference}" wkt ) + assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" +} + +. ${SHUNIT2_HOME}/shunit2 From 18d56cfcd26819e645c400eca6856c07bbb4a7e6 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Mon, 17 Oct 2016 12:58:59 +0200 Subject: [PATCH 05/20] e Signed-off-by: Emmanuel Mathot --- .../Terradue.OpenSearch.Client.csproj | 278 +++++++++--------- 1 file changed, 138 insertions(+), 140 deletions(-) diff --git a/Terradue.OpenSearch.Client/Terradue.OpenSearch.Client.csproj b/Terradue.OpenSearch.Client/Terradue.OpenSearch.Client.csproj index 5c018402..996268a6 100644 --- a/Terradue.OpenSearch.Client/Terradue.OpenSearch.Client.csproj +++ b/Terradue.OpenSearch.Client/Terradue.OpenSearch.Client.csproj @@ -1,143 +1,141 @@ - - Debug - x86 - 8.0.30703 - 2.0 - {1FB59AA7-3878-47CD-4267-F179F56C6470} - Exe - Terradue.OpenSearchClient - OpenSearchClient - - - true - full - false - bin - DEBUG; - prompt - 4 - true - x86 - true - https://data2.terradue.com/eop/sentinel2/dataset/description - true - - - full - true - bin - prompt - 4 - true - x86 - - - - - - - - ..\packages\Terradue.ServiceModel.Syndication.1.0.0.0\lib\net40\Terradue.ServiceModel.Syndication.dll - - - ..\packages\Mono.Addins.1.2\lib\net40\Mono.Addins.dll - - - ..\packages\HtmlAgilityPack.1.4.9\lib\Net40\HtmlAgilityPack.dll - - - - - ..\packages\NetTopologySuite.1.13.3.2\lib\net40-client\NetTopologySuite.dll - - - ..\packages\NetTopologySuite.1.13.3.2\lib\net40-client\PowerCollections.dll - - - ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.ShapeFile.dll - - - ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - - - ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll - - - ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - - - ..\packages\log4net.2.0.5\lib\net40-full\log4net.dll - - - ..\packages\NuGet4Mono.Extensions.0.3.0\lib\net40\NuGet4Mono.Extensions.dll - - - ..\packages\MathNet.Numerics.3.7.1\lib\net40\MathNet.Numerics.dll - - - - ..\packages\ProjNet.1.2\lib\net20\ProjNet.dll - - - ..\packages\Terradue.ServiceModel.Ogc.OwsContext.1.0.6\lib\net40\Terradue.ServiceModel.Ogc.OwsContext.dll - - - ..\packages\GeoAPI.1.7.3.1\lib\net40-client\GeoAPI.dll - - - ..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll - - - ..\packages\Terradue.OpenSearch.RdfEO.1.3.8\lib\net40\Terradue.OpenSearch.RdfEO.dll - - - ..\packages\Terradue.ServiceModel.Ogc.1.1.5\lib\net40\Terradue.ServiceModel.Ogc.dll - - - ..\packages\Terradue.OpenSearch.GeoJson.1.3.8\lib\net40\Terradue.OpenSearch.GeoJson.dll - - - ..\packages\Terradue.GeoJson.1.7.9\lib\net40\Terradue.GeoJson.dll - - - ..\packages\Terradue.Metadata.EarthObservation.1.4.12\lib\net40\Terradue.Metadata.EarthObservation.dll - - - - ..\packages\Terradue.OpenSearch.1.13.0\lib\net40\Terradue.OpenSearch.dll - False - - - ..\packages\Terradue.OpenSearch.SciHub.1.2.2\lib\net40\Terradue.OpenSearch.SciHub.dll - - - - - - - - - - - - - - - - - - - - - - {BFFA2485-B9AC-4DE4-BABF-4DD96590F9D4} - Terradue.OpenSearch.Model - - - {6222FD31-E454-4D76-9AAF-0535787A6A1B} - Terradue.OpenSearch.Model.Base - - + + Debug + x86 + 8.0.30703 + 2.0 + {1FB59AA7-3878-47CD-4267-F179F56C6470} + Exe + Terradue.OpenSearchClient + OpenSearchClient + + + true + full + false + bin + DEBUG; + prompt + 4 + true + x86 + true + https://data2.terradue.com/eop/sentinel2/dataset/description + true + + + full + true + bin + prompt + 4 + true + x86 + + + + + + + + ..\packages\Terradue.ServiceModel.Syndication.1.0.0.0\lib\net40\Terradue.ServiceModel.Syndication.dll + + + ..\packages\Mono.Addins.1.2\lib\net40\Mono.Addins.dll + + + ..\packages\HtmlAgilityPack.1.4.9\lib\Net40\HtmlAgilityPack.dll + + + + + ..\packages\NetTopologySuite.1.13.3.2\lib\net40-client\NetTopologySuite.dll + + + ..\packages\NetTopologySuite.1.13.3.2\lib\net40-client\PowerCollections.dll + + + ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.ShapeFile.dll + + + ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll + + + ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll + + + ..\packages\NetTopologySuite.IO.1.13.3.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll + + + ..\packages\log4net.2.0.5\lib\net40-full\log4net.dll + + + ..\packages\NuGet4Mono.Extensions.0.3.0\lib\net40\NuGet4Mono.Extensions.dll + + + ..\packages\MathNet.Numerics.3.7.1\lib\net40\MathNet.Numerics.dll + + + + ..\packages\ProjNet.1.2\lib\net20\ProjNet.dll + + + ..\packages\Terradue.ServiceModel.Ogc.OwsContext.1.0.6\lib\net40\Terradue.ServiceModel.Ogc.OwsContext.dll + + + ..\packages\GeoAPI.1.7.3.1\lib\net40-client\GeoAPI.dll + + + ..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll + + + ..\packages\Terradue.OpenSearch.RdfEO.1.3.8\lib\net40\Terradue.OpenSearch.RdfEO.dll + + + ..\packages\Terradue.ServiceModel.Ogc.1.1.5\lib\net40\Terradue.ServiceModel.Ogc.dll + + + ..\packages\Terradue.OpenSearch.GeoJson.1.3.8\lib\net40\Terradue.OpenSearch.GeoJson.dll + + + ..\packages\Terradue.GeoJson.1.7.9\lib\net40\Terradue.GeoJson.dll + + + ..\packages\Terradue.Metadata.EarthObservation.1.4.12\lib\net40\Terradue.Metadata.EarthObservation.dll + + + ..\packages\Terradue.OpenSearch.1.13.0\lib\net40\Terradue.OpenSearch.dll + + + ..\packages\Terradue.OpenSearch.SciHub.1.2.2\lib\net40\Terradue.OpenSearch.SciHub.dll + + + + + + + + + + + + + + + + + + + + + + {BFFA2485-B9AC-4DE4-BABF-4DD96590F9D4} + Terradue.OpenSearch.Model + + + {6222FD31-E454-4D76-9AAF-0535787A6A1B} + Terradue.OpenSearch.Model.Base + + \ No newline at end of file From d0934bb3766eaa5676635936fd73c9c03886f769 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 15:36:43 +0200 Subject: [PATCH 06/20] Added more tests --- src/test/tests.d/test_metadata_retrieval.sh | 47 ++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/test/tests.d/test_metadata_retrieval.sh b/src/test/tests.d/test_metadata_retrieval.sh index 9b136256..6739668b 100755 --- a/src/test/tests.d/test_metadata_retrieval.sh +++ b/src/test/tests.d/test_metadata_retrieval.sh @@ -2,12 +2,55 @@ source ./test_common.sh +echo "===== test_metadata_retrieval group =====" + reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" +formats="json atom rdf" + +test_startdate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}?format=${format}" startdate ) + assertEquals "2016-10-15T15:42:22.0260000Z" "${output}" + done +} + +test_enddate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}?format=${format}" enddate ) + assertEquals "2016-10-15T15:45:19.8460000Z" "${output}" + done +} test_wkt() { - local output=$( opensearch-client "${reference}" wkt ) - assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" + for format in ${formats} + do + local output=$( opensearch-client "${reference}?format=${format}" wkt ) + assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" + done +} + +test_enclosure() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}?format=${format}" enclosure ) + # It just check if the protocol http is used (even https passes the test) + assertEquals "http" "${output:0:4}" + done +} + +test_identifier() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}?format=${format}" enclosure ) + assertEquals "S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" + done } . ${SHUNIT2_HOME}/shunit2 From f8653bd447cd98e25fe6751f63b0d50626515bb4 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 15:40:27 +0200 Subject: [PATCH 07/20] Fixed typos --- src/test/tests.d/test_metadata_retrieval.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/tests.d/test_metadata_retrieval.sh b/src/test/tests.d/test_metadata_retrieval.sh index 6739668b..e696abec 100755 --- a/src/test/tests.d/test_metadata_retrieval.sh +++ b/src/test/tests.d/test_metadata_retrieval.sh @@ -11,7 +11,7 @@ test_startdate() { for format in ${formats} do - local output=$( opensearch-client "${reference}?format=${format}" startdate ) + local output=$( opensearch-client "${reference}&format=${format}" startdate ) assertEquals "2016-10-15T15:42:22.0260000Z" "${output}" done } @@ -20,7 +20,7 @@ test_enddate() { for format in ${formats} do - local output=$( opensearch-client "${reference}?format=${format}" enddate ) + local output=$( opensearch-client "${reference}&format=${format}" enddate ) assertEquals "2016-10-15T15:45:19.8460000Z" "${output}" done } @@ -29,7 +29,7 @@ test_wkt() { for format in ${formats} do - local output=$( opensearch-client "${reference}?format=${format}" wkt ) + local output=$( opensearch-client "${reference}&format=${format}" wkt ) assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" done } @@ -38,7 +38,7 @@ test_enclosure() { for format in ${formats} do - local output=$( opensearch-client "${reference}?format=${format}" enclosure ) + local output=$( opensearch-client "${reference}&format=${format}" enclosure ) # It just check if the protocol http is used (even https passes the test) assertEquals "http" "${output:0:4}" done @@ -48,7 +48,7 @@ test_identifier() { for format in ${formats} do - local output=$( opensearch-client "${reference}?format=${format}" enclosure ) + local output=$( opensearch-client "${reference}&format=${format}" enclosure ) assertEquals "S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" done } From 7157a9340882e6ab1674aad67121838d34cc49bf Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:05:34 +0200 Subject: [PATCH 08/20] Added more tests --- ...a_retrieval.sh => test_catalog_geotime.sh} | 4 +- src/test/tests.d/test_catalog_only_rdf.sh | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) rename src/test/tests.d/{test_metadata_retrieval.sh => test_catalog_geotime.sh} (95%) create mode 100755 src/test/tests.d/test_catalog_only_rdf.sh diff --git a/src/test/tests.d/test_metadata_retrieval.sh b/src/test/tests.d/test_catalog_geotime.sh similarity index 95% rename from src/test/tests.d/test_metadata_retrieval.sh rename to src/test/tests.d/test_catalog_geotime.sh index e696abec..140900b5 100755 --- a/src/test/tests.d/test_metadata_retrieval.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -2,7 +2,7 @@ source ./test_common.sh -echo "===== test_metadata_retrieval group =====" +echo "===== test_catalog_geotime =====" reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" formats="json atom rdf" @@ -48,7 +48,7 @@ test_identifier() { for format in ${formats} do - local output=$( opensearch-client "${reference}&format=${format}" enclosure ) + local output=$( opensearch-client "${reference}&format=${format}" identifier ) assertEquals "S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" done } diff --git a/src/test/tests.d/test_catalog_only_rdf.sh b/src/test/tests.d/test_catalog_only_rdf.sh new file mode 100755 index 00000000..ad191934 --- /dev/null +++ b/src/test/tests.d/test_catalog_only_rdf.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +source ./test_common.sh + +echo "===== test_catalog_only_rdf =====" + +reference="http://catalogue.terradue.int/catalogue/search/ASA_IM__0P/ASA_IM__0CNPDE20030611_204630_000000162017_00129_06696_0866.N1" +format="rdf" + +test_startdate() +{ + local output=$( opensearch-client "${reference}/${format}" startdate ) + assertEquals "2003-06-11T20:46:30.6740000Z" "${output}" +} + +test_enddate() +{ + local output=$( opensearch-client "${reference}/${format}" enddate ) + assertEquals "2003-06-11T20:46:46.9540000Z" "${output}" +} + +test_wkt() +{ + local output=$( opensearch-client "${reference}/${format}" wkt ) + assertEquals "MULTIPOLYGON(((14.615052 36.982241,15.776153 37.177145,15.495613 38.242585,14.347516 38.049914,14.615052 36.982241)))" "${output}" +} + +test_enclosure() +{ + local output=$( opensearch-client "${reference/${format}" enclosure ) + assertTrue 'test failed' '[ "http://" = "${output:0:7}" -o "s3://" = "${output:0:5}" ]' +} + +test_identifier() +{ + local output=$( opensearch-client "${reference}/${format}" identifier ) + assertEquals "ASA_IM__0CNPDE20030611_204630_000000162017_00129_06696_0866.N1" "${output}" +} + + +. ${SHUNIT2_HOME}/shunit2 From 22509cba31d51d9d521d589806f30825ffcb3e3b Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:14:00 +0200 Subject: [PATCH 09/20] Fixed typos --- src/test/tests.d/test_catalog_only_rdf.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/tests.d/test_catalog_only_rdf.sh b/src/test/tests.d/test_catalog_only_rdf.sh index ad191934..d8e7187b 100755 --- a/src/test/tests.d/test_catalog_only_rdf.sh +++ b/src/test/tests.d/test_catalog_only_rdf.sh @@ -27,8 +27,8 @@ test_wkt() test_enclosure() { - local output=$( opensearch-client "${reference/${format}" enclosure ) - assertTrue 'test failed' '[ "http://" = "${output:0:7}" -o "s3://" = "${output:0:5}" ]' + local output=$( opensearch-client "${reference}/${format}" enclosure ) + assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" ]" } test_identifier() @@ -38,4 +38,4 @@ test_identifier() } -. ${SHUNIT2_HOME}/shunit2 +. ${SHUNIT2_HOME}/shunit2 \ No newline at end of file From 273c33e091da3a2c398f089d296e784de3c7590b Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:25:56 +0200 Subject: [PATCH 10/20] Added more tests --- src/test/tests.d/test_catalog_geotime.sh | 5 +-- ...log_only_rdf.sh => test_catalog_t2_rdf.sh} | 4 +- src/test/tests.d/test_catalog_va4_rdf.sh | 41 +++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) rename src/test/tests.d/{test_catalog_only_rdf.sh => test_catalog_t2_rdf.sh} (88%) create mode 100755 src/test/tests.d/test_catalog_va4_rdf.sh diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh index 140900b5..a1d05322 100755 --- a/src/test/tests.d/test_catalog_geotime.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -2,7 +2,7 @@ source ./test_common.sh -echo "===== test_catalog_geotime =====" +echo "===== test_catalog_geotime =====" reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" formats="json atom rdf" @@ -39,8 +39,7 @@ test_enclosure() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" enclosure ) - # It just check if the protocol http is used (even https passes the test) - assertEquals "http" "${output:0:4}" + assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" done } diff --git a/src/test/tests.d/test_catalog_only_rdf.sh b/src/test/tests.d/test_catalog_t2_rdf.sh similarity index 88% rename from src/test/tests.d/test_catalog_only_rdf.sh rename to src/test/tests.d/test_catalog_t2_rdf.sh index d8e7187b..806725e6 100755 --- a/src/test/tests.d/test_catalog_only_rdf.sh +++ b/src/test/tests.d/test_catalog_t2_rdf.sh @@ -2,7 +2,7 @@ source ./test_common.sh -echo "===== test_catalog_only_rdf =====" +echo "===== test_catalog_t2_rdf =====" reference="http://catalogue.terradue.int/catalogue/search/ASA_IM__0P/ASA_IM__0CNPDE20030611_204630_000000162017_00129_06696_0866.N1" format="rdf" @@ -28,7 +28,7 @@ test_wkt() test_enclosure() { local output=$( opensearch-client "${reference}/${format}" enclosure ) - assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" ]" + assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" } test_identifier() diff --git a/src/test/tests.d/test_catalog_va4_rdf.sh b/src/test/tests.d/test_catalog_va4_rdf.sh new file mode 100755 index 00000000..2c023958 --- /dev/null +++ b/src/test/tests.d/test_catalog_va4_rdf.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +source ./test_common.sh + +echo "===== test_catalog_va4_rdf =====" + +reference="http://eo-virtual-archive4.esa.int/search/ASA_IM__0P/ASA_IM__0CNPDE20120407_182038_000000173113_00257_52857_6356.N1" +format="rdf" + +test_startdate() +{ + local output=$( opensearch-client "${reference}/${format}" startdate ) + assertEquals "2012-04-07T18:20:38.8100000Z" "${output}" +} + +test_enddate() +{ + local output=$( opensearch-client "${reference}/${format}" enddate ) + assertEquals "2012-04-07T18:20:55.0400000Z" "${output}" +} + +test_wkt() +{ + local output=$( opensearch-client "${reference}/${format}" wkt ) + assertEquals "MULTIPOLYGON(((-120.992484 49.133766,-121.987525 49.24517,-122.270375 48.105365,-121.312357 47.998146,-120.992484 49.133766)))" "${output}" +} + +test_enclosure() +{ + local output=$( opensearch-client "${reference}/${format}" enclosure ) + assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" +} + +test_identifier() +{ + local output=$( opensearch-client "${reference}/${format}" identifier ) + assertEquals "ASA_IM__0CNPDE20120407_182038_000000173113_00257_52857_6356.N1" "${output}" +} + + +. ${SHUNIT2_HOME}/shunit2 \ No newline at end of file From 8007c4a72b9c8ca28bde6df3154474f0297d258f Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:31:52 +0200 Subject: [PATCH 11/20] Fixed pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b8d5820..4cc5ed2e 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ ${basedir}/src/test/ - shunit-test + shunit2-test integration-test exec From c811253cf9bca9227517578ba1c135622bf9a9f0 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:41:47 +0200 Subject: [PATCH 12/20] Updated assertions --- src/test/tests.d/test_catalog_geotime.sh | 5 ++++- src/test/tests.d/test_catalog_t2_rdf.sh | 5 ++++- src/test/tests.d/test_catalog_va4_rdf.sh | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh index a1d05322..c7bfe786 100755 --- a/src/test/tests.d/test_catalog_geotime.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -39,7 +39,10 @@ test_enclosure() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" enclosure ) - assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" + assertTrue '"http" = "${output:0:4}" -o \ + "https" = ${output:0:5}" -o \ + "s3" = "${output:0:2}" -o \ + "ftp" = "${output:0:3}"' done } diff --git a/src/test/tests.d/test_catalog_t2_rdf.sh b/src/test/tests.d/test_catalog_t2_rdf.sh index 806725e6..eb22466c 100755 --- a/src/test/tests.d/test_catalog_t2_rdf.sh +++ b/src/test/tests.d/test_catalog_t2_rdf.sh @@ -28,7 +28,10 @@ test_wkt() test_enclosure() { local output=$( opensearch-client "${reference}/${format}" enclosure ) - assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" + assertTrue '"http" = "${output:0:4}" -o \ + "https" = ${output:0:5}" -o \ + "s3" = "${output:0:2}" -o \ + "ftp" = "${output:0:3}"' } test_identifier() diff --git a/src/test/tests.d/test_catalog_va4_rdf.sh b/src/test/tests.d/test_catalog_va4_rdf.sh index 2c023958..16dde46f 100755 --- a/src/test/tests.d/test_catalog_va4_rdf.sh +++ b/src/test/tests.d/test_catalog_va4_rdf.sh @@ -28,7 +28,10 @@ test_wkt() test_enclosure() { local output=$( opensearch-client "${reference}/${format}" enclosure ) - assertTrue "test failed" "[ \"http://\" = \"${output:0:7}\" -o \"s3://\" = \"${output:0:5}\" -o \"https://\" = \"${output:0:8}\" -o \"ftp://\" = \"${output:0:6}\" ]" + assertTrue '"http" = "${output:0:4}" -o \ + "https" = ${output:0:5}" -o \ + "s3" = "${output:0:2}" -o \ + "ftp" = "${output:0:3}"' } test_identifier() From f251d3f6c85e36c786ba223440fa99c93a68bf35 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 16:56:06 +0200 Subject: [PATCH 13/20] Fixed assertions --- src/test/tests.d/test_catalog_geotime.sh | 5 +---- src/test/tests.d/test_catalog_t2_rdf.sh | 5 +---- src/test/tests.d/test_catalog_va4_rdf.sh | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh index c7bfe786..967a98ba 100755 --- a/src/test/tests.d/test_catalog_geotime.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -39,10 +39,7 @@ test_enclosure() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" enclosure ) - assertTrue '"http" = "${output:0:4}" -o \ - "https" = ${output:0:5}" -o \ - "s3" = "${output:0:2}" -o \ - "ftp" = "${output:0:3}"' + assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" done } diff --git a/src/test/tests.d/test_catalog_t2_rdf.sh b/src/test/tests.d/test_catalog_t2_rdf.sh index eb22466c..155dc25c 100755 --- a/src/test/tests.d/test_catalog_t2_rdf.sh +++ b/src/test/tests.d/test_catalog_t2_rdf.sh @@ -28,10 +28,7 @@ test_wkt() test_enclosure() { local output=$( opensearch-client "${reference}/${format}" enclosure ) - assertTrue '"http" = "${output:0:4}" -o \ - "https" = ${output:0:5}" -o \ - "s3" = "${output:0:2}" -o \ - "ftp" = "${output:0:3}"' + assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" } test_identifier() diff --git a/src/test/tests.d/test_catalog_va4_rdf.sh b/src/test/tests.d/test_catalog_va4_rdf.sh index 16dde46f..8cb5bd4e 100755 --- a/src/test/tests.d/test_catalog_va4_rdf.sh +++ b/src/test/tests.d/test_catalog_va4_rdf.sh @@ -28,10 +28,7 @@ test_wkt() test_enclosure() { local output=$( opensearch-client "${reference}/${format}" enclosure ) - assertTrue '"http" = "${output:0:4}" -o \ - "https" = ${output:0:5}" -o \ - "s3" = "${output:0:2}" -o \ - "ftp" = "${output:0:3}"' + assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" } test_identifier() From 0f159f3dbffbe39b40926171434fb0fb1ad95c64 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 17:25:08 +0200 Subject: [PATCH 14/20] Added more tests --- src/test/tests.d/test_catalog_geotime.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh index 967a98ba..c4364590 100755 --- a/src/test/tests.d/test_catalog_geotime.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -43,6 +43,15 @@ test_enclosure() done } +test_enclosure_do() +{ + for format in ${formats} + do + local output=$( opensearch-client do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) + assertEquals "https://store.terradue.com/download/sentinel2/files/v1/S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" + done +} + test_identifier() { for format in ${formats} @@ -52,4 +61,6 @@ test_identifier() done } + + . ${SHUNIT2_HOME}/shunit2 From b88a61090cce1d54a9d0a8e3525db2ad96198c4b Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 17:25:32 +0200 Subject: [PATCH 15/20] Added more tests --- src/test/tests.d/test_catalog_series.sh | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 src/test/tests.d/test_catalog_series.sh diff --git a/src/test/tests.d/test_catalog_series.sh b/src/test/tests.d/test_catalog_series.sh new file mode 100755 index 00000000..872ac1d2 --- /dev/null +++ b/src/test/tests.d/test_catalog_series.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +source ./test_common.sh + +echo "===== test_catalog_series (TO UPDATE) =====" + +# This test shall be updated with a proper series reference pointing to catalog.terradue.com +reference="https://data2.terradue.com/eop/sentinel1/series/med/search&uid=S1A_IW_GRDH_1SDV_20150324T051221_20150324T051246_005169_00684F_DC61" +formats="json atom rdf" + +test_startdate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" startdate ) + assertEquals "2015-03-24T05:12:21.2441820Z" "${output}" + done +} + +test_enddate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enddate ) + assertEquals "2015-03-24T05:12:46.2438890Z" "${output}" + done +} + +test_wkt() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" wkt ) + assertEquals "POLYGON((13.997004 37.217716,11.114591 37.62225,11.426163 39.123463,14.368804 38.720371,13.997004 37.217716))" "${output}" + done +} + +test_enclosure() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enclosure ) + assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" + done +} + +test_identifier() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" identifier ) + assertEquals "S1A_IW_GRDH_1SDV_20150324T051221_20150324T051246_005169_00684F_DC61" "${output}" + done +} + + +. ${SHUNIT2_HOME}/shunit2 From c7f13e8c5701b7609f7603c6a57bd36e6d7355a6 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 17:47:40 +0200 Subject: [PATCH 16/20] Fixed do parameter --- src/test/run_tests.sh | 6 ++++++ src/test/tests.d/test_catalog_geotime.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/run_tests.sh b/src/test/run_tests.sh index b0b4eb22..715498bf 100755 --- a/src/test/run_tests.sh +++ b/src/test/run_tests.sh @@ -1,6 +1,12 @@ #!/bin/bash +exit_code=0 + for test in $( ls tests.d/* ) do /bin/bash ${test} + res=$? + if [ $res -eq 1 ]; then exit_code=1; fi done + +exit ${exit_code} diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh index c4364590..d72ba79d 100755 --- a/src/test/tests.d/test_catalog_geotime.sh +++ b/src/test/tests.d/test_catalog_geotime.sh @@ -47,7 +47,7 @@ test_enclosure_do() { for format in ${formats} do - local output=$( opensearch-client do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) + local output=$( opensearch-client -p do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) assertEquals "https://store.terradue.com/download/sentinel2/files/v1/S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" done } From a88588852be0a0c99583f68f48d64fb889155e7f Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 18:18:08 +0200 Subject: [PATCH 17/20] Added more tests --- src/test/tests.d/test_catalog_geotime.sh | 66 ------------------------ src/test/tests.d/test_catalog_series.sh | 15 +++--- 2 files changed, 7 insertions(+), 74 deletions(-) delete mode 100755 src/test/tests.d/test_catalog_geotime.sh diff --git a/src/test/tests.d/test_catalog_geotime.sh b/src/test/tests.d/test_catalog_geotime.sh deleted file mode 100755 index d72ba79d..00000000 --- a/src/test/tests.d/test_catalog_geotime.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -source ./test_common.sh - -echo "===== test_catalog_geotime =====" - -reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" -formats="json atom rdf" - -test_startdate() -{ - for format in ${formats} - do - local output=$( opensearch-client "${reference}&format=${format}" startdate ) - assertEquals "2016-10-15T15:42:22.0260000Z" "${output}" - done -} - -test_enddate() -{ - for format in ${formats} - do - local output=$( opensearch-client "${reference}&format=${format}" enddate ) - assertEquals "2016-10-15T15:45:19.8460000Z" "${output}" - done -} - -test_wkt() -{ - for format in ${formats} - do - local output=$( opensearch-client "${reference}&format=${format}" wkt ) - assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" - done -} - -test_enclosure() -{ - for format in ${formats} - do - local output=$( opensearch-client "${reference}&format=${format}" enclosure ) - assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" - done -} - -test_enclosure_do() -{ - for format in ${formats} - do - local output=$( opensearch-client -p do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) - assertEquals "https://store.terradue.com/download/sentinel2/files/v1/S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" - done -} - -test_identifier() -{ - for format in ${formats} - do - local output=$( opensearch-client "${reference}&format=${format}" identifier ) - assertEquals "S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" - done -} - - - -. ${SHUNIT2_HOME}/shunit2 diff --git a/src/test/tests.d/test_catalog_series.sh b/src/test/tests.d/test_catalog_series.sh index 872ac1d2..2cf421b7 100755 --- a/src/test/tests.d/test_catalog_series.sh +++ b/src/test/tests.d/test_catalog_series.sh @@ -2,10 +2,9 @@ source ./test_common.sh -echo "===== test_catalog_series (TO UPDATE) =====" +echo "===== test_catalog_series =====" -# This test shall be updated with a proper series reference pointing to catalog.terradue.com -reference="https://data2.terradue.com/eop/sentinel1/series/med/search&uid=S1A_IW_GRDH_1SDV_20150324T051221_20150324T051246_005169_00684F_DC61" +reference="https://catalog.terradue.com/sentinel1/series/italy/search?uid=S1B_IW_RAW__0SDV_20161017T053650_20161017T053722_002542_0044B5_E4F8" formats="json atom rdf" test_startdate() @@ -13,7 +12,7 @@ test_startdate() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" startdate ) - assertEquals "2015-03-24T05:12:21.2441820Z" "${output}" + assertEquals "2016-10-17T05:36:50.0280230Z" "${output}" done } @@ -22,7 +21,7 @@ test_enddate() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" enddate ) - assertEquals "2015-03-24T05:12:46.2438890Z" "${output}" + assertEquals "2016-10-17T05:37:22.4275890Z" "${output}" done } @@ -31,7 +30,7 @@ test_wkt() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" wkt ) - assertEquals "POLYGON((13.997004 37.217716,11.114591 37.62225,11.426163 39.123463,14.368804 38.720371,13.997004 37.217716))" "${output}" + assertEquals "POLYGON((5.264 37.9473,4.87 35.992,7.5762 35.7226,8.0415 37.6769,5.264 37.9473))" "${output}" done } @@ -40,7 +39,7 @@ test_enclosure() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" enclosure ) - assertTrue "test_enclosure failed" "[ \"http\" = \"${output:0:4}\" -o \"https\" = \"${output:0:5}\" -o \"s3\" = \"${output:0:2}\" -o \"ftp\" = \"${output:0:3}\" ]" + assertEquals "https://store.terradue.com/download/sentinel1/files/v1/S1B_IW_RAW__0SDV_20161017T053650_20161017T053722_002542_0044B5_E4F8" "${output}" done } @@ -49,7 +48,7 @@ test_identifier() for format in ${formats} do local output=$( opensearch-client "${reference}&format=${format}" identifier ) - assertEquals "S1A_IW_GRDH_1SDV_20150324T051221_20150324T051246_005169_00684F_DC61" "${output}" + assertEquals "S1B_IW_RAW__0SDV_20161017T053650_20161017T053722_002542_0044B5_E4F8" "${output}" done } From e467f878fe4d3193fc3d80df3fa6cfb11e0c8a58 Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Mon, 17 Oct 2016 18:18:17 +0200 Subject: [PATCH 18/20] Added more tests --- src/test/tests.d/test_catalog_geotime_L8.sh | 67 +++++++++++++++++++++ src/test/tests.d/test_catalog_geotime_S2.sh | 67 +++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100755 src/test/tests.d/test_catalog_geotime_L8.sh create mode 100755 src/test/tests.d/test_catalog_geotime_S2.sh diff --git a/src/test/tests.d/test_catalog_geotime_L8.sh b/src/test/tests.d/test_catalog_geotime_L8.sh new file mode 100755 index 00000000..7dc391f3 --- /dev/null +++ b/src/test/tests.d/test_catalog_geotime_L8.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +source ./test_common.sh + +echo "===== test_catalog_geotime_L8 =====" + +reference="https://catalog.terradue.com/landsat8/search?uid=LC81422132016290LGN00" +formats="json atom rdf" + +test_startdate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" startdate ) + assertEquals "2016-10-16T06:03:14.1510000Z" "${output}" + done +} + +test_enddate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enddate ) + assertEquals "2016-10-16T06:03:45.9210000Z" "${output}" + done +} + +test_wkt() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" wkt ) + assertEquals "POLYGON((-124.23042 42.82261,-123.694 41.10299,-125.89652 40.69215,-126.49337 42.40881,-124.23042 42.82261))" "${output}" + done +} + +test_enclosure() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enclosure ) + # Here the do parameter shall be set automatically, so we expect always store.terradue.com + assertEquals "https://store.terradue.com/download/landsat8/files/v1/LC81422132016290LGN00" "${output}" + done +} + +test_enclosure_do() +{ + for format in ${formats} + do + local output=$( opensearch-client -p do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) + assertEquals "https://store.terradue.com/download/landsat8/files/v1/LC81422132016290LGN00" "${output}" + done +} + +test_identifier() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" identifier ) + assertEquals "LC81422132016290LGN00" "${output}" + done +} + + + +. ${SHUNIT2_HOME}/shunit2 diff --git a/src/test/tests.d/test_catalog_geotime_S2.sh b/src/test/tests.d/test_catalog_geotime_S2.sh new file mode 100755 index 00000000..0fca6e90 --- /dev/null +++ b/src/test/tests.d/test_catalog_geotime_S2.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +source ./test_common.sh + +echo "===== test_catalog_geotime_S2 =====" + +reference="https://catalog.terradue.com/sentinel2/search?uid=S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" +formats="json atom rdf" + +test_startdate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" startdate ) + assertEquals "2016-10-15T15:42:22.0260000Z" "${output}" + done +} + +test_enddate() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enddate ) + assertEquals "2016-10-15T15:45:19.8460000Z" "${output}" + done +} + +test_wkt() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" wkt ) + assertEquals "POLYGON((-64.7684720805233 59.5263987530396,-62.8274188167669 59.5382353521927,-62.8322923207965 58.5521716221359,-64.7185624545036 58.5407855059116,-64.7684720805233 59.5263987530396))" "${output}" + done +} + +test_enclosure() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" enclosure ) + # Here the do parameter shall be set automatically, so we expect always store.terradue.com + assertEquals "https://store.terradue.com/download/sentinel2/files/v1/S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" + done +} + +test_enclosure_do() +{ + for format in ${formats} + do + local output=$( opensearch-client -p do=sandbox.terradue.int "${reference}&format=${format}" enclosure ) + assertEquals "https://store.terradue.com/download/sentinel2/files/v1/S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" + done +} + +test_identifier() +{ + for format in ${formats} + do + local output=$( opensearch-client "${reference}&format=${format}" identifier ) + assertEquals "S2A_OPER_PRD_MSIL1C_PDMC_20161017T015607_R011_V20161015T154222_20161015T154519" "${output}" + done +} + + + +. ${SHUNIT2_HOME}/shunit2 From c4c362b415d915f93175e57be7e90b68143736fd Mon Sep 17 00:00:00 2001 From: Cesare Rossi Date: Tue, 18 Oct 2016 15:24:21 +0200 Subject: [PATCH 19/20] Skipping L8 wkt json test --- src/test/tests.d/test_catalog_geotime_L8.sh | 4 +++- .../{test_catalog_series.sh => test_catalog_series_S1.sh} | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) rename src/test/tests.d/{test_catalog_series.sh => test_catalog_series_S1.sh} (97%) diff --git a/src/test/tests.d/test_catalog_geotime_L8.sh b/src/test/tests.d/test_catalog_geotime_L8.sh index 7dc391f3..47608669 100755 --- a/src/test/tests.d/test_catalog_geotime_L8.sh +++ b/src/test/tests.d/test_catalog_geotime_L8.sh @@ -27,7 +27,9 @@ test_enddate() test_wkt() { - for format in ${formats} + # There's a bug in the catalogue (2016-10-18) for the json response. Skipping this test for the moment + #for format in ${formats} + for format in atom rdf do local output=$( opensearch-client "${reference}&format=${format}" wkt ) assertEquals "POLYGON((-124.23042 42.82261,-123.694 41.10299,-125.89652 40.69215,-126.49337 42.40881,-124.23042 42.82261))" "${output}" diff --git a/src/test/tests.d/test_catalog_series.sh b/src/test/tests.d/test_catalog_series_S1.sh similarity index 97% rename from src/test/tests.d/test_catalog_series.sh rename to src/test/tests.d/test_catalog_series_S1.sh index 2cf421b7..37c871e6 100755 --- a/src/test/tests.d/test_catalog_series.sh +++ b/src/test/tests.d/test_catalog_series_S1.sh @@ -2,7 +2,7 @@ source ./test_common.sh -echo "===== test_catalog_series =====" +echo "===== test_catalog_series_S1 =====" reference="https://catalog.terradue.com/sentinel1/series/italy/search?uid=S1B_IW_RAW__0SDV_20161017T053650_20161017T053722_002542_0044B5_E4F8" formats="json atom rdf" From 9dffacee575a382816cb89307f3c26e28823e412 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Tue, 18 Oct 2016 15:39:54 +0200 Subject: [PATCH 20/20] ready to pack 1.6.4 Signed-off-by: Emmanuel Mathot --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4cc5ed2e..fc7fa694 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ opensearch-client rpm OpenSearch Client - 1.6.4-SNAPSHOT + 1.6.4 opensearch-client