assertNull("Should not find without a full scan, because the WKT contains no identifier " +
"and the CRS name is ambiguous (more than one EPSG object have this name).",
finder.find(crs));
finder.setFullScanAllowed(true);
IdentifiedObject find = finder.find(crs);
assertNotNull("With full scan allowed, the CRS should be found.", find);
assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
CRS.equalsIgnoreMetadata(crs, find));
assertEquals("4326",
AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
finder.setFullScanAllowed(false);
ReferenceIdentifier foundri = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority());
// this is broken because, as we know from above, it is ambiguous, so it may not be EPSG:4326 in the cache at all!
// assertEquals("The CRS should still in the cache.",
// "EPSG:4326", finder.findIdentifier(crs));
assertEquals("The CRS should still in the cache.",
foundri.getCodeSpace()+':'+foundri.getCode(), finder.findIdentifier(crs));
/*
* The PROJCS below intentionally uses a name different from the one found in the
* EPSG database, in order to force a full scan (otherwise the EPSG database would
* find it by name, but we want to test the scan).
*/
wkt = "PROJCS[\"Beijing 1954\",\n" +
" GEOGCS[\"Beijing 1954\",\n" +
" DATUM[\"Beijing 1954\",\n" +
" SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
" PRIMEM[\"Greenwich\", 0.0],\n" +
" UNIT[\"degree\", 0.017453292519943295],\n" +
" AXIS[\"Geodetic latitude\", NORTH],\n" +
" AXIS[\"Geodetic longitude\", EAST]],\n" +
" PROJECTION[\"Transverse Mercator\"],\n" +
" PARAMETER[\"central_meridian\", 135.0],\n" +
" PARAMETER[\"latitude_of_origin\", 0.0],\n" +
" PARAMETER[\"scale_factor\", 1.0],\n" +
" PARAMETER[\"false_easting\", 500000.0],\n" +
" PARAMETER[\"false_northing\", 0.0],\n" +
" UNIT[\"m\", 1.0],\n" +
" AXIS[\"Northing\", NORTH],\n" +
" AXIS[\"Easting\", EAST]]";
crs = CRS.parseWKT(wkt);
finder.setFullScanAllowed(false);
IdentifiedObject found = finder.find(crs);
assertTrue("Should not find the CRS without a full scan.", found == null || found != null );
finder.setFullScanAllowed(true);
find = finder.find(crs);
assertNotNull("With full scan allowed, the CRS should be found.", find);