Skip to content
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

Error downloading filtered dataset, where filter is based on another layer #8603

Closed
1 task done
DavidQuartz opened this issue Sep 22, 2022 · 3 comments
Closed
1 task done

Comments

@DavidQuartz
Copy link
Contributor

DavidQuartz commented Sep 22, 2022

Description

Downloading filtered layer data for a layer which was filtered based on another layer does not work.

How to reproduce

  • Create a new map
  • Add 2 layers in the same region
  • Filter one layer and set the other as Target Layer
  • Choose 'Intersects' as Operation
  • Save Filter
  • Download the filtered dataset
Screenshot 2022-09-22 at 08 59 16

Expected Result

The layer data is downloaded

Current Result

An error is thrown

Screenshot 2022-09-22 at 08 50 52
  • Not browser related
Browser info (use this site: https://www.whatsmybrowser.org/ for non expert users)
Browser Affected Version
Internet Explorer
Edge
Chrome
Firefox
Safari

Other useful information

You may test with this map. It already contains a filtered dataset (Colorado Populated Places).
From the network tab, this error is thrown

<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 https://development.demo.geonode.org/geoserver/schemas/ows/1.1.0/owsAll.xsd">
<ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>
        Could not parse XML request.
        The element type "wps:ComplexData" must be terminated by the matching end-tag "</wps:ComplexData>".
    </ows:ExceptionText>
</ows:Exception>
@DavidQuartz
Copy link
Contributor Author

@tdipisa @giohappy I find that the issue stems from how the filter is being parsed here
Such filter data seems to already contain come CDATA, and so wrapping it in CDATA breaks the xml syntax.
A proposed solution would be limit the cdata function to only wrap data which does not already include cdata.

@allyoucanmap
Copy link
Contributor

@DavidQuartz could you please make a comment with the old broken xml payload and the new one?

@DavidQuartz
Copy link
Contributor Author

@allyoucanmap Here is an example of an old broken xml payload

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://www.opengis.net/wps/1.0.0"
	xmlns:wfs="http://www.opengis.net/wfs"
	xmlns:wps="http://www.opengis.net/wps/1.0.0"
	xmlns:ows="http://www.opengis.net/ows/1.1"
	xmlns:gml="http://www.opengis.net/gml"
	xmlns:ogc="http://www.opengis.net/ogc"
	xmlns:wcs="http://www.opengis.net/wcs/1.1.1"
	xmlns:dwn="http://geoserver.org/wps/download"
	xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
	<ows:Identifier>gs:DownloadEstimator</ows:Identifier>
	<wps:DataInputs>
		<wps:Input>
			<ows:Identifier>layerName</ows:Identifier>
			<wps:Data>
				<wps:LiteralData>geonode:ProvCM01012019_g_WGS84_lKHiGZ3</wps:LiteralData>
			</wps:Data>
		</wps:Input>
		<wps:Input>
			<ows:Identifier>filter</ows:Identifier>
			<wps:Data>
				<wps:ComplexData mimeType="text/xml; subtype=filter/1.1">
					<![CDATA[<ogc:Filter
					xmlns:ogc="http://www.opengis.net/ogc"
					xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:Intersects><ogc:PropertyName>the_geom</ogc:PropertyName><ogc:Function name="collectGeometries"><ogc:Function name="queryCollection"><ogc:Literal>geonode:test_export_filter0</ogc:Literal><ogc:Literal>the_geom</ogc:Literal><ogc:Literal>
					<![CDATA[INCLUDE]]>
				</ogc:Literal>
			</ogc:Function>
		</ogc:Function>
	</ogc:Intersects>
</ogc:And></ogc:Filter>]]>undefined</wps:ComplexData>undefined</wps:Data>undefined</wps:Input>undefined</wps:DataInputs>undefined</wps:Execute>

And here is the fixed version of it

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://www.opengis.net/wps/1.0.0"
	xmlns:wfs="http://www.opengis.net/wfs"
	xmlns:wps="http://www.opengis.net/wps/1.0.0"
	xmlns:ows="http://www.opengis.net/ows/1.1"
	xmlns:gml="http://www.opengis.net/gml"
	xmlns:ogc="http://www.opengis.net/ogc"
	xmlns:wcs="http://www.opengis.net/wcs/1.1.1"
	xmlns:dwn="http://geoserver.org/wps/download"
	xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
	<ows:Identifier>gs:DownloadEstimator</ows:Identifier>
	<wps:DataInputs>
		<wps:Input>
			<ows:Identifier>layerName</ows:Identifier>
			<wps:Data>
				<wps:LiteralData>geonode:ProvCM01012019_g_WGS84_lKHiGZ3</wps:LiteralData>
			</wps:Data>
		</wps:Input>
		<wps:Input>
			<ows:Identifier>filter</ows:Identifier>
			<wps:Data>
				<wps:ComplexData mimeType="text/xml; subtype=filter/1.1">
					<ogc:Filter
						xmlns:ogc="http://www.opengis.net/ogc"
						xmlns:gml="http://www.opengis.net/gml">
						<ogc:And>
							<ogc:Intersects>
								<ogc:PropertyName>the_geom</ogc:PropertyName>
								<ogc:Function name="collectGeometries">
									<ogc:Function name="queryCollection">
										<ogc:Literal>geonode:test_export_filter0</ogc:Literal>
										<ogc:Literal>the_geom</ogc:Literal>
										<ogc:Literal>
											<![CDATA[INCLUDE]]>
										</ogc:Literal>
									</ogc:Function>
								</ogc:Function>
							</ogc:Intersects>
						</ogc:And>
					</ogc:Filter>
				</wps:ComplexData>
			</wps:Data>
		</wps:Input>
	</wps:DataInputs>
</wps:Execute>

@DavidQuartz DavidQuartz assigned DavidQuartz and unassigned tdipisa Sep 29, 2022
@tdipisa tdipisa added this to the 2022.02.01 milestone Sep 29, 2022
@ElenaGallo ElenaGallo self-assigned this Oct 3, 2022
DavidQuartz added a commit to DavidQuartz/MapStore2 that referenced this issue Oct 3, 2022
DavidQuartz added a commit to DavidQuartz/MapStore2 that referenced this issue Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants