Hello Andrea
Hmm, so instead of CRS.lookupEpsgCode(refSys, true), you would suggest
something like:
SRID = CRS.lookupIdentifier(refSys, true);
if (SRID != null)
SRID = SRID.substring(SRID.indexOf(':')+1);
If I understand it well, the advantage is that this will work even if
the authority being used (or the authority that has a matching code for
the refSys) is not the EPSG one, right?
Actually, when I read your e-mail I thought at first about using:
SRID = CRS.lookupIdentifier(Citations.POSTGIS, refSys, true);
But then it returned null - I guess because the Postgis EPSG jar is not
being used (and shouldn't be, right? only one epsg jar at a time, if I
recall correctly..?)
Thanks
Milton
Andrea Aime wrote:
>> 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.
>
--
Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502
-------------------------------------------------------------------------
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