Re: [Geoserver-users] How to map the same feature from alternate data sources in WFS

2020-05-14 Thread Stein, Michael P [US] (TS)

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:


   
   123 Main St
  Mytown
   
   Office
   
  
  2017
  9
  2018-01-01
  
  
  2018
  92000
  2019-01-01
  
  
  2019
  96000
  2020-01-01
  
  
  2020
  99000
  



Sometimes I really do want the above unabridged form for every 
BuildingType=Office in my database. The filter below will do it:


  
 BuildingType
 Office
  
   

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:


   
   123 Main St
  Mytown
   
   Office
   
  
  2020
  99000
  




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:


   
   123 Main St
  Mytown
   
   Office
  
  2017
  9
  


   
   123 Main St
  Mytown
   
   Office
  
  2018
  92000
  


   
   123 Main St
  Mytown
   
   Office
  
  2019
  96000
  


   
   123 Main St
  Mytown
   
   Office
  
  2020
  99000
  


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 
Sent: Thursday, May 14, 2020 19:54
To: Stein, Michael P [US] (TS) 
Cc: geoserver-users@lists.sourceforge.net
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:mike.st...@ngc.com]
Sent: Friday, 15 May 2020 12:42 AM
To: Humphries, Graham 
mailto:graham.humphr...@stategrowth.tas.gov.au>>
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:


  
 
myns:FeatureDetails/myns:FeatureDetail/myns:color
 red
  
   

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 
d

[Geoserver-users] How to map the same feature from alternate data sources in WFS

2020-05-13 Thread Stein, Michael P [US] (TS)
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:FeatureIdentification>...
 < myns:FeatureDetails>
 < myns:FeatureDetail>
  < myns:StartDate>2015-08-20
  < myns:EndDate>2016-03-01
  < myns:color>red
  < myns:cost>3.99
  
 < myns:FeatureDetail>
  < myns:StartDate>2016-03-02
  < myns:EndDate>2018-12-15
  < myns:color>green
  < myns:cost>3.99
  
  
 < myns:FeatureDetail>
  < myns:StartDate>2018-12-16
  < myns:EndDate/>
  < myns:color>red
  < myns:cost>4.29
  


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'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:

  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 ... 

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

___
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