This commit contains the addition of two caches and a change in a SQL statement.
The SQL statement has been rewritten (there is no more INNER JOIN
or sub-query for that statement in SIS).
However the idea of using caches has been kept, but the code is written in a different way and does not cache exactly the same thing.
For example the axisCounts
cache added in this commit works with CoordinateReferenceSystem
(CRS) objects,
while the cache in SIS works with CoordinateSystem
(CS) objects (this is one more step toward low-level objects in ISO 19111 model).
That cache is named csDimensions
in SIS to make clear that it is about the dimension of coordinate systems.
Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r20576:20577 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
Revision 20576 | Revision 20577 |
---|---|
private final Map/*<String,AxisName>*/ axisNames = new HashMap(); /** * Pool of naming systems, used for caching. * There is usually few of them (about 15). */ |
private final Map/*<String,AxisName>*/ axisNames = new HashMap(); /** * Cache for axis numbers. This service is not provided by {@link BufferedAuthorityFactory} * since the number of axis is used internally in this class. * * @see #getAxisName */ private final Map/*<String,axisCount>*/ axisCounts = new HashMap(); /** * Cache for projection checks. This service is not provided by {@link BufferedAuthorityFactory} * since the check that a transformation is a projection is used internally in this class. * * @see #getAxisName */ private final Map/*<String,projection>*/ codeProjection = new HashMap(); /** * Pool of naming systems, used for caching. * There is usually few of them (about 15). */ |
*/ private short getDimensionForCRS(final String code) throws SQLException { final PreparedStatement stmt; stmt = prepareStatement("Dimension", "SELECT COUNT(CA.COORD_AXIS_CODE)" + " FROM [Coordinate Axis] AS CA" + " INNER JOIN [Coordinate Reference System] AS CRS" + " ON (CA.COORD_SYS_CODE = CRS.COORD_SYS_CODE)" + " WHERE (CRS.COORD_REF_SYS_CODE = ?)"); stmt.setString(1, code); final ResultSet result = stmt.executeQuery(); final short dimension = result.next() ? result.getShort(1) : 2; result.close(); return dimension; } |
*/ private short getDimensionForCRS(final String code) throws SQLException { final PreparedStatement stmt; Short returnValue = (Short) axisCounts.get(code); final short dimension; if (returnValue == null) { stmt = prepareStatement("Dimension", " SELECT COUNT(COORD_AXIS_CODE)" + " FROM [Coordinate Axis]" + " WHERE COORD_SYS_CODE = (SELECT COORD_SYS_CODE " + " FROM [Coordinate Reference System]" + " WHERE COORD_REF_SYS_CODE = ?)"); stmt.setString(1, code); final ResultSet result = stmt.executeQuery(); dimension = result.next() ? result.getShort(1) : 2; axisCounts.put(code, new Short(dimension)); result.close(); } else { dimension = returnValue.shortValue(); } return dimension; } |
*/ final boolean isProjection(final String code) throws SQLException { final PreparedStatement stmt; stmt = prepareStatement("isProjection", "SELECT COORD_REF_SYS_CODE" + " FROM [Coordinate Reference System]" + " WHERE PROJECTION_CONV_CODE = ?" |
*/ final boolean isProjection(final String code) throws SQLException { final PreparedStatement stmt; Boolean projection = (Boolean) codeProjection.get(code); if(projection == null) { stmt = prepareStatement("isProjection", "SELECT COORD_REF_SYS_CODE" + " FROM [Coordinate Reference System]" + " WHERE PROJECTION_CONV_CODE = ?" |
final ResultSet result = stmt.executeQuery();
final boolean found = result.next();
result.close();
return found;
}
/**
* Returns a coordinate operation from a code. |
final ResultSet result = stmt.executeQuery(); final boolean found = result.next(); result.close(); projection = Boolean.valueOf(found); codeProjection.put(code, projection); } return projection.booleanValue(); } /** * Returns a coordinate operation from a code. |