Milton Jonathan ha scritto:
> Hello there
>
> I exchanged some e-mails a while ago with Jody, about issues with
> spatial references when creating a schema on PostgisDataStore. Please see:
> http://n2.nabble.com/SRID-problems-when-writing-to-PostGIS-td1093252.html
Yeah, generally speaking the createSchema() methods are not tested much,
basically because no one of the main software that use GeoTools
(GeoServer and uDig) uses them (uDig uses the one of the shapefile,
but I believe that's it).
So do expect some rough ride (well, expect a rough ride on anything
that's not used by GeoServer or uDig in anger, period ;-) ).
> I guess the conversation kind of died out, but we here did implement
> what I see as the solution to the problem. Basically, I exchanged lines
> 1287-1298 with the following code:
>
> if (ident == null || ident.isEmpty()){
> if (refSys == DefaultGeographicCRS.WGS84)
> SRID = 4326;
> else
> SRID = CRS.lookupEpsgCode(refSys, true);
> }
> else{
> String code = ((NamedIdentifier) ident.toArray()[0]).getCode();
> SRID = Integer.parseInt(code);
> }
Aah, ok, I see, you're trying to get an EPSG code out of our
CRS definition, right? That's may not be the best way either, since most
shapefiles (that I hear you're trying to import into databases)
have a .prj file that does not have the numeric identifier or
else that uses datum names other than the ones used by the
official EPSG database. Anyways, the best best you have to
get back a SRID out of a CoordinateReferenceSystem object is using
CRS.lookupIdentifier.
Without full scan it will just return the id contained in the
CoordinateReferenceSystem, if it has any, and if it matches an official
EPSG code. With full scan it will go an extra mile and compare the
CRS will all EPSG official CRS, and return a matching one provided
the CRS uses the same parameters and the same datum name as an
official code.
> If it's OK with you, I can open up a JIRA task and send the patch over
> there. I'm just not sure about the best way to implement a test for
> that, though, since method createSchema() is quite large and uses tests
> shared with DataTestCase, something like that. One thing we could do
> would be to separate the task of figuring out the SRID as an independent
> private or protected method (say, "getSRID"), and then use Java
> reflection to access that method for testing purposes. Just an idea.
A separate protected method should be good enough, yeah. I'm looking
forward to see the test, I can try to replicate something similar
in the new jdbc datastores.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel