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;
}
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);
}
Aggregations