We do not treat the historic data as a separate feature from the current data.
There is only one instance of the top-level feature, no matter how much history
it has. All its history is _internal_ to the one and only instance of the
feature. What we want is for the user to be able to choose an abridged version
of the feature, or an unabridged version of the feature, in response to exactly
the same filter.
Let's say we have buildings as a feature, and buildings are of various types -
offices, flats, stores, warehouses, etc. Part of the data for a feature is its
valuation for tax purposes. Below is a building built in 2017, in unabridged
form showing all tax assessment history attached to the building:
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessments>
<TaxAssessment>
<TaxYear>2017</TaxYear>
<Value>90000</Value>
<DateArchived>2018-01-01</DateArchived>
</TaxAssessment>
<TaxAssessment>
<TaxYear>2018</TaxYear>
<Value>92000</Value>
<DateArchived>2019-01-01</DateArchived>
</TaxAssessment>
<TaxAssessment>
<TaxYear>2019</TaxYear>
<Value>96000</Value>
<DateArchived>2020-01-01</DateArchived>
</TaxAssessment>
<TaxAssessment>
<TaxYear>2020</TaxYear>
<Value>99000</Value>
</TaxAssessment>
</TaxAssessments>
</Building>
Sometimes I really do want the above unabridged form for every
BuildingType=Office in my database. The filter below will do it:
<fes:Filter>
<fes:PropertyIsEqualTo>
<fes:ValueReference>BuildingType</fes:ValueReference>
<fes:Literal>Office</fes:Literal>
</fes:PropertyIsEqualTo>
</fes:Filter>
Other times, however, I am not interested in the history. All I want is the
abridged form below, representing just the current year for every Office:
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessments>
<TaxAssessment>
<TaxYear>2020</TaxYear>
<Value>99000</Value>
</TaxAssessment>
</TaxAssessments>
</Building>
How can I get GeoServer to give me my choice of the two results? I have even
added your DateArchived. What filter would give me the second, abridged format
for all my office buildings?
What you are suggesting would work if our output looked like this:
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessment>
<TaxYear>2017</TaxYear>
<Value>90000</Value>
</TaxAssessment>
</Building>
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessment>
<TaxYear>2018</TaxYear>
<Value>92000</Value>
</TaxAssessment>
</Building>
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessment>
<TaxYear>2019</TaxYear>
<Value>96000</Value>
</TaxAssessment>
</Building>
<Building>
<Address>
<StreetAddr> 123 Main St</StreetAddr>
<City>Mytown</City>
<Address>
<BuildingType>Office</BuildingType>
<TaxAssessment>
<TaxYear>2020</TaxYear>
<Value>99000</Value>
</TaxAssessment>
</Building>
Then I could filter on both the building type and the tax year, and get the
combination of Office and tax year 2020. Unfortunately, that is not the schema
definition we are using.
From: Humphries, Graham <[email protected]>
Sent: Thursday, May 14, 2020 19:54
To: Stein, Michael P [US] (TS) <[email protected]>
Cc: [email protected]
Subject: EXT :RE: How to map the same feature from alternate data sources in WFS
Probably should keep the discussion on the list. Other people might have a
better understanding of your problem than me.
The way we handle our historic data is by having a date_archived field in the
table. If the data is current the date_archived value is null. When this record
is suprceded the date_archived is populated with the date when this occurs.
This makes filtering historic and current data simple ie: date_archived is null
or date_archived is not null.
From: Stein, Michael P [US] (TS) [mailto:[email protected]]
Sent: Friday, 15 May 2020 12:42 AM
To: Humphries, Graham
<[email protected]<mailto:[email protected]>>
Subject: RE: How to map the same feature from alternate data sources in WFS
(I am responding to you directly, not the list.)
I am not entirely sure where you are suggesting this filtering be established.
We could certainly post-process the existing output to remove all but the
current detail record, but that would be a significant performance hit. We want
the filtering to be done in the initial SQL query for maximum performance.
We could also stand up a separate instance of GeoServer with the alternative
mappings, but the customer is not going to be happy with the idea of buying
additional system capacity to support that solution.
If you are suggesting adding the filter to the request, there are two problems
with this. One problem is that we do not want to burden the end user with the
task of creating a complex filter that they must remember to edit every time
they run it to put in a new value corresponding to "today". The stickier
problem is that a filter is a filter on the feature as a whole, not on
sub-elements of the feature. Any feature that has one detail item that matches
the filter on detail items will bring back all the detail. Using my example
feature, if I were to filter for color red in the request as follows:
<fes:Filter>
<fes:PropertyIsEqualTo>
<fes:ValueReference>myns:FeatureDetails/myns:FeatureDetail/myns:color</fes:ValueReference>
<fes:Literal>red</fes:Literal>
</fes:PropertyIsEqualTo>
</fes:Filter>
it is interpreted as "return any feature having at least one detail with the
color red". The feature as a whole is considered a match and the feature as a
whole comes back in the response, including the green detail.
If you are suggesting something other than the above, please explain in more
detail.
From: Humphries, Graham
<[email protected]<mailto:[email protected]>>
Sent: Wednesday, May 13, 2020 18:19
To: Stein, Michael P [US] (TS) <[email protected]<mailto:[email protected]>>;
[email protected]<mailto:[email protected]>
Subject: EXT :RE: How to map the same feature from alternate data sources in WFS
Couldn't you duplicate the feature set with a filter to only show the current
data?
From: Stein, Michael P [US] (TS) [mailto:[email protected]]
Sent: Thursday, 14 May 2020 3:20 AM
To:
[email protected]<mailto:[email protected]>
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<https://aus01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.myns.com%2Fschema%2F1.0%3ATheFeautreType&data=02%7C01%7CGraham.Humphries%40stategrowth.tas.gov.au%7C3ae62099a7bd4f67972108d7f8150bed%7C64ebab8accf44b5ca2d32b4e972d96b2%7C0%7C0%7C637250641602641377&sdata=uB0qV8xiIVPu5sXqerrDyQDwHcZ81Vy0b5wFU2Sj54U%3D&reserved=0>.
myns:TheFeature ns:
http://www.myns.com<https://aus01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.myns.com%2F&data=02%7C01%7CGraham.Humphries%40stategrowth.tas.gov.au%7C3ae62099a7bd4f67972108d7f8150bed%7C64ebab8accf44b5ca2d32b4e972d96b2%7C0%7C0%7C637250641602641377&sdata=kFKY1cN3bd5gSOs63sHj0xFfDFvBnFdtwZcxnO9ksfI%3D&reserved=0>,
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%7C3ae62099a7bd4f67972108d7f8150bed%7C64ebab8accf44b5ca2d32b4e972d96b2%7C0%7C0%7C637250641602651371&sdata=EmGWbN%2FX1EuULLmnS03oWUcrUXmsD%2BQtKYuW0Fr6olY%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.
________________________________
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users