Skip to content

Spatial filter error (via KVP or JSON binding) #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Joe-Heffer-Shef opened this issue Mar 31, 2020 · 1 comment
Open

Spatial filter error (via KVP or JSON binding) #793

Joe-Heffer-Shef opened this issue Mar 31, 2020 · 1 comment

Comments

@Joe-Heffer-Shef
Copy link

Joe-Heffer-Shef commented Mar 31, 2020

Hi,

We're attempting to use the 52deg North Sensor Observation Service APIs provided by DEFRA UK-AIR (i.e. UK government air quality data service).

We're struggling to use the spatial filter feature of the GetObservation endpoint. It's throwing errors that I don't understand. I don't know whether this is user error, a problem with the 52deg North software, or a problem at caused by misconfiguration of the DEFRA system.

I don't know where the best place is to discuss problems with this system so I'll ask here. Please refer me to a more appropriate contact if you can.

I'm calling the API using HTTP requests in Python. I'm happy to share the code, but I'll summarise what I'm doing below.

These are the parameters I'm requesting (shown in JSON format for simplicity of presentation). This is send using the Key-value pair (KVP) binding.

{
    "service": "SOS",
    "namespaces": "xmlns(om,http://www.opengis.net/om/2.0)",
    "spatialFilter": "om:featureOfInterest/*/sams:shape,-1.24,53.46,-1.68,53.24",
    "version": "2.0.0",
    "request": "GetObservation"
}
<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd">
  <ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>An error occurred while querying feature identifiers for spatial filter!
[EXEPTION]: 
could not extract ResultSet</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

We also get the same error when using the JSON binding.

The request is defined by OGC SOS 12-006 Requirement 116 -- KVP encoding and I've followed OGC 06-121r3 section 10.2.3 Bounding box KVP encoding:

A WGS 84 bounding box shall be KVP encoded in a corresponding parameter
value list, with the ordered listed values for the quantities:

            LowerCorner longitude, in decimal degrees
            LowerCorner latitude, in decimal degrees
            UpperCorner longitude, in decimal degrees
            UpperCorner latitude, in decimal degrees
            crs URI = “urn:ogc:def:crs:OGC:1.3:CRS84” (optional)

I'm finding that the provided examples don't work.

Sometimes I see this error:

<html><head><title>Apache Tomcat/7.0.82 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - 1</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>1</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.ArrayIndexOutOfBoundsException: 1
        org.n52.sos.decode.kvp.AbstractKvpDecoder.parseNamespaces(AbstractKvpDecoder.java:357)
        org.n52.sos.decode.kvp.v2.GetObservationKvpDecoderv20.decode(GetObservationKvpDecoderv20.java:132)
        org.n52.sos.decode.kvp.v2.GetObservationKvpDecoderv20.decode(GetObservationKvpDecoderv20.java:62)
        org.n52.sos.binding.KvpBinding.parseRequest(KvpBinding.java:162)
        org.n52.sos.binding.KvpBinding.doGetOperation(KvpBinding.java:96)
        org.n52.sos.service.SosService.doGet(SosService.java:125)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        org.n52.sos.service.ConfiguratedHttpServlet.service(ConfiguratedHttpServlet.java:53)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
        org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
        org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
        org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
        org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:168)
        com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:233)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.82 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.82</h3></body></html>
@shreyashkumar01
Copy link

Hello @Joe-Heffer-Shef ,
Thank you for providing the stack trace. It confirms that the issue is occurring during the decoding of the KVP request for the spatial filter, specifically within the GetObservationKvpDecoder.
Let's break down the stack trace:

  • Decoding Error: The presence of org.n52.sos.decode.kvp.v2.GetObservationKvpDecoder indicates that the SOS is failing to interpret the spatial filter parameters you've provided in the KVP request.
  • Security Filters: The numerous Spring Security filters suggest that authentication or authorization might be playing a role. It's possible that the request is being blocked or modified before it reaches the decoder.
    Here's how we can investigate further:
  • KVP Formatting:
    • Carefully review the OGC specifications for bounding box encoding in KVP. Pay close attention to the order and format of the parameters (longitude, latitude, CRS URI).
    • Compare your request's KVP formatting with the examples provided in the SOS documentation (if available) or other working SOS implementations.
    • Try simplifying the spatial filter to a very basic bounding box to see if that works.
  • SOS Configuration:
    • Examine the 52North SOS configuration files, especially those related to KVP decoding and security.
    • Look for any settings that might be affecting the GetObservationKvpDecoder or the Spring Security filters.
    • Check for any custom configurations that might be overriding the default behavior.
  • Security Context:
    • If you have authentication enabled, ensure that your request is properly authenticated.
    • Investigate the Spring Security filter chain to understand how the request is being processed.
    • Temporarily disable security filters (if possible in a test environment) to see if that resolves the issue.
  • API Documentation:
    • Revisit the 52North SOS documentation for any specific requirements or limitations related to the GetObservation endpoint and spatial filtering.
  • Community Support:
    • Consider reaching out to the 52North SOS community or support channels for assistance. Provide them with the full stack trace and details of your request.
      By systematically investigating these areas, you should be able to identify the root cause of the decoding failure. Remember to test changes incrementally and document your findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants