Search in sources :

Example 1 with LineType

use of ch.interlis.ili2c.metamodel.LineType in project ili2db by claeis.

the class FromXtfRecordConverter method getSrsid.

public int getSrsid(AttributeDef attr) {
    Integer srsid = srsCache.get(attr);
    if (srsid != null) {
        return srsid;
    }
    ch.interlis.ili2c.metamodel.Element attrOrDomainDef = attr;
    ch.interlis.ili2c.metamodel.Type attrType = attr.getDomain();
    if (attrType instanceof ch.interlis.ili2c.metamodel.TypeAlias) {
        attrOrDomainDef = ((ch.interlis.ili2c.metamodel.TypeAlias) attrType).getAliasing();
        attrType = ((Domain) attrOrDomainDef).getType();
    }
    CoordType coord = null;
    if (attrType instanceof CoordType) {
        coord = (CoordType) attrType;
    } else if (attrType instanceof LineType) {
        Domain coordDomain = ((LineType) attrType).getControlPointDomain();
        if (coordDomain != null) {
            attrOrDomainDef = coordDomain;
            coord = (CoordType) coordDomain.getType();
        }
    }
    if (coord != null) {
        String crs = coord.getCrs(attrOrDomainDef);
        if (crs != null) {
            String[] crsv = crs.split(":");
            String crsAuthority = crsv[0];
            String crsCode = crsv[1];
            try {
                srsid = geomConv.getSrsid(crsAuthority, crsCode, conn);
                if (srsid != null) {
                    srsCache.put(attr, srsid);
                    return srsid;
                }
            } catch (UnsupportedOperationException ex) {
                EhiLogger.logAdaption("no CRS support by converter; use default " + defaultSrsid);
            } catch (ConverterException ex) {
                throw new IllegalArgumentException("failed to get srsid for " + crsAuthority + ":" + crsCode + ", " + ex.getLocalizedMessage());
            }
        }
    }
    srsid = defaultSrsid;
    srsCache.put(attr, srsid);
    return srsid;
}
Also used : ConverterException(ch.ehi.ili2db.converter.ConverterException) Domain(ch.interlis.ili2c.metamodel.Domain) Type(ch.interlis.ili2c.metamodel.Type) LineType(ch.interlis.ili2c.metamodel.LineType) CoordType(ch.interlis.ili2c.metamodel.CoordType)

Example 2 with LineType

use of ch.interlis.ili2c.metamodel.LineType in project ili2db by claeis.

the class AbstractRecordConverter method setCrs.

public void setCrs(DbColGeometry ret, AttributeDef attr) {
    ch.interlis.ili2c.metamodel.Element attrOrDomainDef = attr;
    ch.interlis.ili2c.metamodel.Type attrType = attr.getDomain();
    if (attrType instanceof ch.interlis.ili2c.metamodel.TypeAlias) {
        attrOrDomainDef = ((ch.interlis.ili2c.metamodel.TypeAlias) attrType).getAliasing();
        attrType = ((Domain) attrOrDomainDef).getType();
    }
    CoordType coord = null;
    if (attrType instanceof CoordType) {
        coord = (CoordType) attrType;
    } else if (attrType instanceof LineType) {
        Domain coordDomain = ((LineType) attrType).getControlPointDomain();
        if (coordDomain != null) {
            attrOrDomainDef = coordDomain;
            coord = (CoordType) coordDomain.getType();
        }
    }
    if (coord != null) {
        String crs = coord.getCrs(attrOrDomainDef);
        if (crs != null) {
            String[] crsv = crs.split(":");
            ret.setSrsAuth(crsv[0]);
            ret.setSrsId(crsv[1]);
            return;
        }
    }
    ret.setSrsAuth(defaultCrsAuthority);
    ret.setSrsId(defaultCrsCode);
}
Also used : Domain(ch.interlis.ili2c.metamodel.Domain) LineType(ch.interlis.ili2c.metamodel.LineType) CoordType(ch.interlis.ili2c.metamodel.CoordType)

Aggregations

CoordType (ch.interlis.ili2c.metamodel.CoordType)2 Domain (ch.interlis.ili2c.metamodel.Domain)2 LineType (ch.interlis.ili2c.metamodel.LineType)2 ConverterException (ch.ehi.ili2db.converter.ConverterException)1 Type (ch.interlis.ili2c.metamodel.Type)1