Maybe by creating all available CRS and checking each created CRS...if it's
equal to the CRS created by WKT.

This will create an array with all available CRS:




> CoordinateReferenceSystem[] cache;
> 
> 
> int progress = 0;
> 
> int maximum = 1;
> 
> if (cache == null) {
>               
>             CRSAuthorityFactory crsfactory =
> FactoryFinder.getCRSAuthorityFactory("EPSG");
>             Set codes = crsfactory.getAuthorityCodes();
> 
>             maximum = codes.size();
> 
>             ArrayList list = new ArrayList(maximum);
>             Iterator it = codes.iterator();
>             
>             while (it.hasNext()) {
>               
>                 String str = (String)it.next();
> 
>                 if (str.startsWith("EPSG:")) {
>                       
>                     str = str.substring(5);
>                 }
> 
>                 try {
>                       
>                     CoordinateReferenceSystem crs =
> crsfactory.createCoordinateReferenceSystem(str);
>                     if (crs != null){
>                         list.add(crs);
>                         
>                     }
>                 } catch (Exception ex){
>                       
>                     Logger logger =
> Logger.getLogger("com.gdv.geometry.projections");
>                     logger.log(Level.INFO, "Unable to create CRS No.: '" +
> str + "'");
>                 }
>                 progress++;
>             }
> 
>             cache = (CoordinateReferenceSystem[])list.toArray(new
> CoordinateReferenceSystem[list.size()]);
>         }
> 

Check if there's any EPSG code that matches the same definition:

CoordinateReferenceSystem crsWKT = createCRSbyWKT(SOURCE_WKT);



> for (int i=0; i < cache.length(); i++){
>    if(cache[i].getName().equals(crsWKT.getName())){
>      // Match!!!
>     }
> }
> 

Something like that....

Regards
-- 
View this message in context: 
http://www.nabble.com/From-WKT-to-equivalent-EPSG-code-%28if-possible-at-all...%29-tf2807927.html#a7835627
Sent from the geotools-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to