Revision 48 trunk/org.gvsig.mysql/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/operations/MySQLFetchFeatureTypeOperation.java

View differences:

MySQLFetchFeatureTypeOperation.java
9 9
import java.util.HashMap;
10 10
import java.util.List;
11 11
import java.util.Map;
12
import org.apache.commons.lang3.StringUtils;
13 12
import org.cresques.cts.IProjection;
14 13
import org.gvsig.fmap.dal.DataTypes;
15 14
import org.gvsig.fmap.dal.exception.DataException;
......
26 25

  
27 26
public class MySQLFetchFeatureTypeOperation extends FetchFeatureTypeOperation {
28 27

  
29
    private static Map<String,GeometryType>spatialiteGeometryTypes = null;
28
    private static Map<String,GeometryType>mySQLGeometryTypes = null;
30 29
    
31 30
    public MySQLFetchFeatureTypeOperation(
32 31
            JDBCHelper helper
......
69 68
            ResultSetMetaData rsMetadata,
70 69
            int colIndex
71 70
        ) throws SQLException {
72
        // En SpatiaLite no existe el tipo de dato Geometria, las geometrias
73
        // se guardan en un BLOB, y en getColumnTypeName se indica el tipo
74
        // de la geometria.
75 71
        if( rsMetadata.getColumnType(colIndex) != java.sql.Types.BINARY ) {
76 72
            return super.getDataTypeFromMetadata(rsMetadata, colIndex);
77 73
        }
78 74
        String typeName = rsMetadata.getColumnTypeName(colIndex);
79
        GeometryType gt = getGeometryTypeFromSpatiaLiteTypeName(typeName);
75
        GeometryType gt = getGeometryTypeFromMySQLTypeName(typeName);
80 76
        if( gt==null ) {
81 77
            return super.getDataTypeFromMetadata(rsMetadata, colIndex);
82 78
        }
......
94 90
        }
95 91
        try {
96 92
            String typeName = rsMetadata.getColumnTypeName(colIndex);
97
            GeometryType gt = getGeometryTypeFromSpatiaLiteTypeName(typeName);
93
            GeometryType gt = getGeometryTypeFromMySQLTypeName(typeName);
98 94
            if( gt != null ) {
99 95
                attr.setGeometryType(gt);
100 96

  
......
145 141
        }
146 142
    }
147 143

  
148
    private GeometryType getGeometryTypeFromSpatiaLiteTypeName(String typeName) {
149
        if( spatialiteGeometryTypes==null ) {
144
    private GeometryType getGeometryTypeFromMySQLTypeName(String typeName) {
145
        if( mySQLGeometryTypes==null ) {
150 146
            GeometryManager manager = GeometryLocator.getGeometryManager();
151
            spatialiteGeometryTypes = new HashMap<>();
152
            spatialiteGeometryTypes.put("POINT", getGT(manager, Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D));
147
            mySQLGeometryTypes = new HashMap<>();
148
            mySQLGeometryTypes.put("POINT", getGT(manager, Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D));
153 149
            
154
            spatialiteGeometryTypes.put("LINESTRING", getGT(manager, Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D));
150
            mySQLGeometryTypes.put("LINESTRING", getGT(manager, Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D));
155 151
            
156
            spatialiteGeometryTypes.put("POLYGON", getGT(manager, Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D));
152
            mySQLGeometryTypes.put("POLYGON", getGT(manager, Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D));
157 153

  
158
            spatialiteGeometryTypes.put("MULTIPOINT", getGT(manager, Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D));
154
            mySQLGeometryTypes.put("MULTIPOINT", getGT(manager, Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D));
159 155

  
160
            spatialiteGeometryTypes.put("MULTILINESTRING", getGT(manager, Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D));
156
            mySQLGeometryTypes.put("MULTILINESTRING", getGT(manager, Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D));
161 157

  
162
            spatialiteGeometryTypes.put("MULTIPOLYGON", getGT(manager, Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D));
158
            mySQLGeometryTypes.put("MULTIPOLYGON", getGT(manager, Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D));
163 159

  
164
            spatialiteGeometryTypes.put("GEOMETRY", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D));
160
            mySQLGeometryTypes.put("GEOMETRY", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D));
165 161
        }
166
        return spatialiteGeometryTypes.get(typeName);
162
        return mySQLGeometryTypes.get(typeName);
167 163
    }
168 164
    
169 165
}

Also available in: Unified diff