use of org.opengis.referencing.NoSuchAuthorityCodeException in project sis by apache.
the class AuthorityFactoryMock method createUnit.
/**
* Returns the unit of measurement for the given code.
*
* @return the unit of measurement.
* @throws NoSuchAuthorityCodeException if the given code is unknown.
*/
@Override
public Unit<?> createUnit(final String code) throws NoSuchAuthorityCodeException {
assertFalse("This factory has been closed.", isClosed());
final int n;
try {
n = Integer.parseInt(trimNamespace(code));
} catch (NumberFormatException e) {
throw new NoSuchAuthorityCodeException(e.toString(), "MOCK", code);
}
final Unit<?> unit = Units.valueOfEPSG(n);
if (unit == null) {
throw new NoSuchAuthorityCodeException(code, authority.getTitle().toString(), code);
}
return unit;
}
use of org.opengis.referencing.NoSuchAuthorityCodeException in project sis by apache.
the class AuthorityFactoryMock method createExtent.
/**
* Returns the spatial extent for the given code.
*
* @return the spatial extent.
* @throws NoSuchAuthorityCodeException if the given code is unknown.
*/
@Override
public Extent createExtent(final String code) throws NoSuchAuthorityCodeException {
assertFalse("This factory has been closed.", isClosed());
final int n;
try {
n = Integer.parseInt(trimNamespace(code));
} catch (NumberFormatException e) {
throw new NoSuchAuthorityCodeException(e.toString(), "MOCK", code);
}
switch(n) {
case 1262:
return Extents.WORLD;
default:
throw new NoSuchAuthorityCodeException(code, authority.getTitle().toString(), code);
}
}
use of org.opengis.referencing.NoSuchAuthorityCodeException in project chordatlas by twak.
the class PanoGen method createPanoGen.
private void createPanoGen(File f, List<Pano> results) {
String name = f.getName().substring(0, f.getName().length() - 4);
try {
String[] sVals = name.split("[_]", 10);
if (sVals.length < 6)
return;
List<Double> pos = Arrays.asList(Arrays.copyOfRange(sVals, 0, 6)).stream().map(z -> Double.parseDouble(z)).collect(Collectors.toList());
double[] trans = new double[] { pos.get(0), pos.get(1), 0 };
double[] north = new double[] { pos.get(0), pos.get(1) + 1e-6, 0 };
// two part transform to align heights - geoid for 4326 is different to 27700
MathTransform latLong2Country = CRS.findMathTransform(CRS.decode(sourceCRS), CRS.decode(TweedSettings.settings.gmlCoordSystem), true);
latLong2Country.transform(trans, 0, trans, 0, 1);
latLong2Country.transform(north, 0, north, 0, 1);
if (TweedSettings.settings.gmlCoordSystem.equals("EPSG:3042")) {
/* madrid?! */
System.out.println("******* dirty hack in place for flipped CS");
double tmp = trans[0];
trans[0] = trans[1];
trans[1] = tmp;
}
MathTransform country2Cartesian = CRS.findMathTransform(CRS.decode(TweedSettings.settings.gmlCoordSystem), DefaultGeocentricCRS.CARTESIAN, true);
country2Cartesian.transform(trans, 0, trans, 0, 1);
country2Cartesian.transform(north, 0, north, 0, 1);
{
Point3d tmp = new Point3d(trans);
TweedSettings.settings.toOrigin.transform(tmp);
tmp.get(trans);
tmp = new Point3d(north);
TweedSettings.settings.toOrigin.transform(tmp);
tmp.get(north);
}
if (TweedSettings.settings.gmlCoordSystem.equals("EPSG:2062")) {
// oviedo :(
trans[2] -= 258;
north[2] -= 258;
trans[0] += 3;
trans[0] += 3;
}
Vector3d location = new Vector3d(trans[0], 2.5f, /* camera height above floor */
trans[2]);
{
Vector3d west = new Vector3d((float) (trans[0] - north[0]), 0f, (float) (north[2] - trans[2]));
west.scale(0.6f / west.length());
location.add(west);
}
System.out.println("pano@ " + location);
results.add(new Pano(name, location, // + 360 - (toNorth * 180 /FastMath.PI ) ) % 360,
(pos.get(3).floatValue() + 180), pos.get(4).floatValue(), pos.get(5).floatValue()));
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
} catch (NoSuchAuthorityCodeException e) {
e.printStackTrace();
} catch (FactoryException e) {
e.printStackTrace();
} catch (TransformException e) {
e.printStackTrace();
}
}
Aggregations