Couldn't you duplicate the feature set with a filter to only show the current data?
From: Stein, Michael P [US] (TS) [mailto:mike.st...@ngc.com] Sent: Thursday, 14 May 2020 3:20 AM To: geoserver-users@lists.sourceforge.net Subject: [Geoserver-users] How to map the same feature from alternate data sources in WFS We are currently in the process of upgrading from Geoserver 2.10 to 2.16; what follows is from our 2.10 installation. We have a feature that carries historic detail. Our current mapping returns an XML representation of the feature containing all of the historic detail. E.g., <myns:TheFeature> < myns:FeatureIdentification>...</ myns:FeatureIdentification> < myns:FeatureDetails> < myns:FeatureDetail> < myns:StartDate>2015-08-20</ myns:StartDate> < myns:EndDate>2016-03-01</ myns:StartDate> < myns:color>red</ myns:color> < myns:cost>3.99</ myns:cost> </ myns:FeatureDetail> < myns:FeatureDetail> < myns:StartDate>2016-03-02</ myns:StartDate> < myns:EndDate>2018-12-15</ myns:StartDate> < myns:color>green</ myns:color> < myns:cost>3.99</ myns:cost> </ myns:FeatureDetail> <!-- Null end date means this is the last record in the time sequence --> < myns:FeatureDetail> < myns:StartDate>2018-12-16</ myns:StartDate> < myns:EndDate/> < myns:color>red</ myns:color> < myns:cost>4.29</ myns:cost> </ myns:FeatureDetail> </ myns:TheFeature> Sometimes we want this complete historical record, but other times we want to omit the history and return only the detail currently in effect - the detail with a start date of 2018-12-16 in the example above. I thought to do this by adding an element TheFeatureCurrent to the XML schema and to GeoServer mapping. Like TheFeature, it is defined as being of TheFeatureType. I then added a mapping for TheFeatureCurrent as a copy of the mapping for TheFeature, except that instead of the table FEATURE_DETAIL, the database source for the detail would be a view FEATURE_DETAIL_CURRENT_VIEW that restricted the detail to just those rows covering the current date. Although the mapping file was ostensibly for TheFeatureCurrent, the new mapping file actually mapped to the same TheFeature element rather than TheFeatureCurrent. I discovered that I needed to modify all the mapping names in the new mapping file to not match the mapping names in the mapping file for the original feature. If I did not do that, I got errors like java.lang.RuntimeException: org.geotools.data.DataSourceException: Duplicate mappingName or targetElement across FeatureTypeMapping instances detected. They have to be unique, or app-schema doesn&apos;t know which one to get. Please check your mapping file(s) with mappingName or targetElement of: myns_SomeSubFeature org.geotools.data.DataSourceException: ... Once I changed all the mapping names, I got: <ns3:ExceptionText>java.lang.RuntimeException: Error applying mapping with targetAttribute myns:TheFeature Error applying mapping with targetAttribute myns:TheFeature myns:TheFeature is not a valid location path for type http://www.myns.com/schema/1.0:TheFeautreType. myns:TheFeature ns: http://www.myns.com, TheFeatureType properties: http://www.opengis.net/gml/3.2#metaDataProperty<https://aus01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.opengis.net%2Fgml%2F3.2%23metaDataProperty&data=02%7C01%7CGraham.Humphries%40stategrowth.tas.gov.au%7Cfeb55bb15a71458e654608d7f76478e6%7C64ebab8accf44b5ca2d32b4e972d96b2%7C0%7C0%7C637249883853885739&sdata=IJKjTV910Tl4jn7AtMI9Um23%2BOxywageRHLFACPG%2F9A%3D&reserved=0> ... </ns3:ExceptionText> I _can_ get it to return results with TheFeatureCurrent by consistently changing the mapping throughout, but we don't want to return that unfamiliar element to the user. We could post-process the XML output to convert the element name, but that would require additional software development add extra processing time on large result sets. I have not yet tried creating a parallel namespace currns to hold a duplicate of the myns schema, but that is also something I'd like to avoid. Any suggestions? --------------------------------------------------------------- Michael Stein, Northrop Grumman Defense Systems ________________________________ CONFIDENTIALITY NOTICE AND DISCLAIMER The information in this transmission may be confidential and/or protected by legal professional privilege, and is intended only for the person or persons to whom it is addressed. If you are not such a person, you are warned that any disclosure, copying or dissemination of the information is unauthorised. If you have received the transmission in error, please immediately contact this office by telephone, fax or email, to inform us of the error and to enable arrangements to be made for the destruction of the transmission, or its return at our cost. No liability is accepted for any unauthorised use of the information contained in this transmission.
_______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users