Search in sources :

Example 21 with NoSuchAuthorityCodeException

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;
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException)

Example 22 with NoSuchAuthorityCodeException

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);
    }
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException)

Example 23 with NoSuchAuthorityCodeException

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();
    }
}
Also used : Color(java.awt.Color) FactoryException(org.opengis.referencing.FactoryException) XStream(com.thoughtworks.xstream.XStream) Arrays(java.util.Arrays) CRS(org.geotools.referencing.CRS) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) ClickMe(org.twak.tweed.ClickMe) Random(java.util.Random) Mode(com.jme3.scene.Mesh.Mode) PlaneTool(org.twak.tweed.tools.PlaneTool) Vector4f(com.jme3.math.Vector4f) IDumpObjs(org.twak.tweed.IDumpObjs) Material(com.jme3.material.Material) TransformException(org.opengis.referencing.operation.TransformException) Point3d(javax.vecmath.Point3d) VertexBuffer(com.jme3.scene.VertexBuffer) BufferedImage(java.awt.image.BufferedImage) ListDownLayout(org.twak.utils.ui.ListDownLayout) DefaultGeocentricCRS(org.geotools.referencing.crs.DefaultGeocentricCRS) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) Dimension(java.awt.Dimension) List(java.util.List) Mesh(com.jme3.scene.Mesh) JPanel(javax.swing.JPanel) Geometry(com.jme3.scene.Geometry) ActionListener(java.awt.event.ActionListener) FacadeTool(org.twak.tweed.tools.FacadeTool) Vector2f(com.jme3.math.Vector2f) Vector3d(javax.vecmath.Vector3d) Filez(org.twak.utils.Filez) Mosaic(org.twak.readTrace.Mosaic) Tweed(org.twak.tweed.Tweed) ArrayList(java.util.ArrayList) TweedSettings(org.twak.tweed.TweedSettings) Spatial(com.jme3.scene.Spatial) Graphics2D(java.awt.Graphics2D) Mathz(org.twak.utils.Mathz) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) Iterator(java.util.Iterator) Files(java.nio.file.Files) BufferUtils(com.jme3.util.BufferUtils) Vector3f(com.jme3.math.Vector3f) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) MathTransform(org.opengis.referencing.operation.MathTransform) Jme3z(org.twak.siteplan.jme.Jme3z) EventMoveHandle(org.twak.tweed.EventMoveHandle) ObjDump(org.twak.utils.geom.ObjDump) ColorRGBA(com.jme3.math.ColorRGBA) JTextArea(javax.swing.JTextArea) Box(com.jme3.scene.shape.Box) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) MathTransform(org.opengis.referencing.operation.MathTransform) FactoryException(org.opengis.referencing.FactoryException) TransformException(org.opengis.referencing.operation.TransformException) Vector3d(javax.vecmath.Vector3d) Point3d(javax.vecmath.Point3d)

Aggregations

NoSuchAuthorityCodeException (org.opengis.referencing.NoSuchAuthorityCodeException)23 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)8 FactoryException (org.opengis.referencing.FactoryException)7 InternationalString (org.opengis.util.InternationalString)5 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 File (java.io.File)2 ResultSet (java.sql.ResultSet)2 Identifier (org.opengis.metadata.Identifier)2 Citation (org.opengis.metadata.citation.Citation)2 Material (com.jme3.material.Material)1 ColorRGBA (com.jme3.math.ColorRGBA)1 Vector2f (com.jme3.math.Vector2f)1 Vector3f (com.jme3.math.Vector3f)1 Vector4f (com.jme3.math.Vector4f)1 Geometry (com.jme3.scene.Geometry)1 Mesh (com.jme3.scene.Mesh)1 Mode (com.jme3.scene.Mesh.Mode)1