Index: org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/CrsFactory.java =================================================================== --- org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/CrsFactory.java (revisione 747) +++ org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/CrsFactory.java (copia locale) @@ -390,6 +390,7 @@ } String source_sr_name = sr.GetAttrValue(attr); + sr.StripCTParms(); EpsgConnection conn = new EpsgConnection(); conn.setConnectionEPSG(); @@ -407,16 +408,17 @@ logger.debug("Trying to match EPSG:{}...", code); SpatialReference target_sr = new SpatialReference(); target_sr.ImportFromEPSG(code); - target_sr.MorphToESRI(); + String target_sr_name = target_sr.GetAttrValue(attr); + target_sr.StripCTParms(); + logger.debug("Source SR name: {}", source_sr_name); + logger.debug("Target SR name: {}", target_sr_name); if (bProj4) { - sr.MorphToESRI(); String source_proj4 = sr.ExportToProj4(); + String target_proj4 = target_sr.ExportToProj4(); logger.debug("Source proj4: {}", source_proj4); - String target_proj4 = target_sr.ExportToProj4(); logger.debug("Target proj4: {}", target_proj4); if (StringUtils.equals(source_proj4, target_proj4)) { - String target_sr_name = target_sr.GetAttrValue(attr); - dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeESRI(target_sr_name)); + dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeEPSG(target_sr_name)); if (dist == 0) { logger.debug("EPSG:{} matches!", code); return code; @@ -423,8 +425,7 @@ } } } else { - String target_sr_name = target_sr.GetAttrValue(attr); - dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeESRI(target_sr_name)); + dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeEPSG(target_sr_name)); if (dist == 0) { logger.debug("EPSG:{} matches!", code); return code; @@ -499,7 +500,6 @@ String name; name = StringUtils.replace(sr_name, "GCS_", ""); name = StringUtils.replaceChars(name, "()", ""); - name = StringUtils.replace(name, "St_", "St. "); name = StringUtils.replace(name, "WGS_19", "WGS "); // e.g. WGS_1984 --> WGS 84 name = StringUtils.replace(name, "_19", ""); // e.g. NAD_1927 --> NAD27 name = StringUtils.replace(name, "_20", "20"); // e.g. ITRF_2008 --> ITRF2008 @@ -533,12 +533,22 @@ name = StringUtils.replace(name, "New_Brunswick_Stereographic", "New Brunswick Stereographic (ATS77)"); name = StringUtils.replace(name, "Oslo_Norway", "(Oslo) NGO"); name = StringUtils.replace(name, "Paris", "(Paris)"); + name = StringUtils.replace(name, "St_", "St. "); name = StringUtils.replace(name, "TC_1948", "TC(1948)"); name = StringUtils.replace(name, "_", " "); + name = StringUtils.replace(name, "-", " "); name = StringUtils.lowerCase(name); return name; } + + public String normalizeEPSG(String sr_name) { + String name; + name = StringUtils.replace(sr_name, " / ", " "); + name = StringUtils.replace(name, "-", " "); + name = StringUtils.lowerCase(name); + return name; + } /* (non-Javadoc) * @see org.cresques.cts.ICRSFactory#export(java.lang.String, org.cresques.cts.IProjection)