* {@link VerticalDatumType#GEOIDAL}. We don't know yet how
* to maps the exact vertical datum type from the EPSG database.
*/
public synchronized Datum generateDatum(final String code) throws FactoryException {
ensureNonNull("code", code);
Datum returnValue = null;
try {
final String primaryKey = toPrimaryKey(Datum.class, code,
"[Datum]", "DATUM_CODE", "DATUM_NAME");
final PreparedStatement stmt;
stmt = prepareStatement("Datum", "SELECT DATUM_CODE,"
+ " DATUM_NAME,"
+ " DATUM_TYPE,"
+ " ORIGIN_DESCRIPTION,"
+ " REALIZATION_EPOCH,"
+ " AREA_OF_USE_CODE,"
+ " DATUM_SCOPE,"
+ " REMARKS,"
+ " ELLIPSOID_CODE," // Only for geodetic type
+ " PRIME_MERIDIAN_CODE" // Only for geodetic type
+ " FROM [Datum]"
+ " WHERE DATUM_CODE = ?");
stmt.setString(1, primaryKey);
ResultSet result = stmt.executeQuery();
while (result.next()) {
final String epsg = getString(result, 1, code);
final String name = getString(result, 2, code);
final String type = getString(result, 3, code).trim().toLowerCase();
final String anchor = result.getString( 4);
final String epoch = result.getString( 5);
final String area = result.getString( 6);
final String scope = result.getString( 7);
final String remarks = result.getString( 8);
Map<String,Object> properties = generateProperties(name, epsg, area, scope, remarks);
if (anchor != null) {
properties.put(Datum.ANCHOR_POINT_KEY, anchor);
}
if (epoch!=null && epoch.length()!=0) try {
calendar.clear();
calendar.set(Integer.parseInt(epoch), 0, 1);
properties.put(Datum.REALIZATION_EPOCH_KEY, calendar.getTime());
} catch (NumberFormatException exception) {
// Not a fatal error...
Logging.unexpectedException(LOGGER, AbstractEpsgFactory.class, "createDatum", exception);
}
final DatumFactory factory = factories.getDatumFactory();
final Datum datum;
/*
* Now build datum according their datum type. Constructions are straightforward,
* except for the "geodetic" datum type which need some special processing:
*
* - Because it invokes again 'generateProperties' indirectly (through calls to