390 |
390 |
}
|
391 |
391 |
|
392 |
392 |
String source_sr_name = sr.GetAttrValue(attr);
|
|
393 |
sr.StripCTParms();
|
393 |
394 |
|
394 |
395 |
EpsgConnection conn = new EpsgConnection();
|
395 |
396 |
conn.setConnectionEPSG();
|
... | ... | |
407 |
408 |
logger.debug("Trying to match EPSG:{}...", code);
|
408 |
409 |
SpatialReference target_sr = new SpatialReference();
|
409 |
410 |
target_sr.ImportFromEPSG(code);
|
410 |
|
target_sr.MorphToESRI();
|
|
411 |
String target_sr_name = target_sr.GetAttrValue(attr);
|
|
412 |
target_sr.StripCTParms();
|
|
413 |
logger.debug("Source SR name: {}", source_sr_name);
|
|
414 |
logger.debug("Target SR name: {}", target_sr_name);
|
411 |
415 |
if (bProj4) {
|
412 |
|
sr.MorphToESRI();
|
413 |
416 |
String source_proj4 = sr.ExportToProj4();
|
|
417 |
String target_proj4 = target_sr.ExportToProj4();
|
414 |
418 |
logger.debug("Source proj4: {}", source_proj4);
|
415 |
|
String target_proj4 = target_sr.ExportToProj4();
|
416 |
419 |
logger.debug("Target proj4: {}", target_proj4);
|
417 |
420 |
if (StringUtils.equals(source_proj4, target_proj4)) {
|
418 |
|
String target_sr_name = target_sr.GetAttrValue(attr);
|
419 |
|
dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeESRI(target_sr_name));
|
|
421 |
dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeEPSG(target_sr_name));
|
420 |
422 |
if (dist == 0) {
|
421 |
423 |
logger.debug("EPSG:{} matches!", code);
|
422 |
424 |
return code;
|
423 |
425 |
}
|
424 |
426 |
}
|
425 |
427 |
} else {
|
426 |
|
String target_sr_name = target_sr.GetAttrValue(attr);
|
427 |
|
dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeESRI(target_sr_name));
|
|
428 |
dist = StringUtils.getLevenshteinDistance(normalizeESRI(source_sr_name), normalizeEPSG(target_sr_name));
|
428 |
429 |
if (dist == 0) {
|
429 |
430 |
logger.debug("EPSG:{} matches!", code);
|
430 |
431 |
return code;
|
... | ... | |
499 |
500 |
String name;
|
500 |
501 |
name = StringUtils.replace(sr_name, "GCS_", "");
|
501 |
502 |
name = StringUtils.replaceChars(name, "()", "");
|
502 |
|
name = StringUtils.replace(name, "St_", "St. ");
|
503 |
503 |
name = StringUtils.replace(name, "WGS_19", "WGS "); // e.g. WGS_1984 --> WGS 84
|
504 |
504 |
name = StringUtils.replace(name, "_19", ""); // e.g. NAD_1927 --> NAD27
|
505 |
505 |
name = StringUtils.replace(name, "_20", "20"); // e.g. ITRF_2008 --> ITRF2008
|
... | ... | |
533 |
533 |
name = StringUtils.replace(name, "New_Brunswick_Stereographic", "New Brunswick Stereographic (ATS77)");
|
534 |
534 |
name = StringUtils.replace(name, "Oslo_Norway", "(Oslo) NGO");
|
535 |
535 |
name = StringUtils.replace(name, "Paris", "(Paris)");
|
|
536 |
name = StringUtils.replace(name, "St_", "St. ");
|
536 |
537 |
name = StringUtils.replace(name, "TC_1948", "TC(1948)");
|
537 |
538 |
|
538 |
539 |
name = StringUtils.replace(name, "_", " ");
|
|
540 |
name = StringUtils.replace(name, "-", " ");
|
539 |
541 |
name = StringUtils.lowerCase(name);
|
540 |
542 |
return name;
|
541 |
543 |
}
|
|
544 |
|
|
545 |
public String normalizeEPSG(String sr_name) {
|
|
546 |
String name;
|
|
547 |
name = StringUtils.replace(sr_name, " / ", " ");
|
|
548 |
name = StringUtils.replace(name, "-", " ");
|
|
549 |
name = StringUtils.lowerCase(name);
|
|
550 |
return name;
|
|
551 |
}
|
542 |
552 |
|
543 |
553 |
/* (non-Javadoc)
|
544 |
554 |
* @see org.cresques.cts.ICRSFactory#export(java.lang.String, org.cresques.cts.IProjection)
|