Hey all,
I chatted with Justin a bit about this earlier, but I think I've resolved
GEOS-1330. I discovered two things doing this, which I wanted to run by the
gs folks (particularly Andrea) and then I'll send the relevant parts to the
geotools lists to make sure I'm on the right track.
1) I think the fundamental problem was that line 328 of KMLTranslator.java
was just plain doing the wrong thing. Query.setCoordinateSystem()
(according to the javadocs) is supposed to be a declarative 'this is the
coordinate system of this featurecollection, and I will query it using this
coord sys'. At the minimum, it acts that way (see how
AbstractFeatureSource.getFeatures() treats it).
So when we called q.setCoordinateSystem(mapContext.getCoordSys()) this
simply told the featureSource that we were asserting that data inside that
featuresource was in that coordsys. So the returned FeatureResults from
that query wound up being asserted to be in mapContext.getCoordsys() (4326,
generally) and the ReprojectFeatureResults wound up wrapping a
DefaultFeatureResults that declared that it was returning features in 4326
-> so there was no reprojection.
I'll double-check with the gt crowd about how this is *supposed* to work,
but as I see it right now, if you know your featureSource has a legit crs
connected to it, then you shouldn't set q.setCoordinateSystem...you should
set q.setCoordinateSystemReproject() (if you want reprojection) or you
should set nothing.
2) Separately, I think I found a tricky bug in ReprojectFeatureResults
constructor. The bug is outlined here, by showing the current logic of the
constructor:
ReprojectFeatureResults(FeatureResults originalResults, CRS targetCoordSys)
{
a. Build a featuretype which is exactly like the ft of originalResults,
only with the coordsys co-erced to targetCoordsys (for those who will ask us
about our featureType)
b. Figure out if originalResults is ALSO a
ReprojectFeatureResults/ForceFeatureResults...cause if it is let's skip that
(now defunct) reprojection, and simply reproject the underlying results.
c. Get the coordsys of the originalResults, and if it's different than the
targetCoordsys, then find the right transform and remember it.
}
So the bug is that step b looks at the UNDERLYING results (which are
probably in a different coordsys) and step c looks at the PASSED-IN results.
This is almost always going to be a bug, and probably means that non-trivial
attepmts to ReprojectFeatureResults() a ReprojectFeatureResults probably
hasn't worked for a while.
Anyway, I fixed both 1 and 2 by:
* changing 1 to q.setCoordSysReproject() and
* changing line 98 of ReprojectFeatureResults.java to
CoordinateReferenceSystem originalCs =
this.results.getSchema().getDefaultGeometry().getCoordinateSystem();
Mostly I'm looking for some confirmation that this makes sense (all tests
pass in geotools and geoserver) and that I should go pester the GT list
about confirming that I'm right about #1 and that #2 really is a bug.
--saul
--
View this message in context: http://www.nabble.com/GEOS-1330%2C-or-ReprojectFeatueResults-wrapping-a-ReprojectFeatureResults-tf4604159.html#a13146465
Sent from the GeoServer - Dev mailing list archive at Nabble.com.