I did some quick tests on windows box yesterday and everything worked.
Tomorrow I will test the code on ,my brand new linux box to see if
there are problems there.
Aside from this, it is not clear to me what you are trying to do.
Could you provide some details on this code?
Simone.
On 11/7/06, Simone Giannecchini <[EMAIL PROTECTED]> wrote:
> Ciao Christopher,
> I did some quick tests on windows box yesterday and everything worked.
>
> Tomorrow I will test the code on ,my brand new linux box to see if
> there are problems there.
>
> Aside from this, it is not clear to me what you are trying to do.
> Could you provide some details on this code?
>
>
> Simone.
>
> On 11/6/06, Christopher Hammack <[EMAIL PROTECTED]> wrote:
> > Thank you for responding.
> >
> > Here is some sample code. I can't seem to make it work with any non EPSG
> > CRS. I compiled against 2.3M0.
> >
> >
> > Code below:
> >
> > import java.awt.image.RenderedImage;
> > import java.io.File;
> > import java.io.IOException;
> >
> > import javax.imageio.ImageIO;
> >
> > import org.geotools.coverage.grid.GridCoverage2D;
> > import org.geotools.coverage.grid.GridCoverageFactory;
> > import org.geotools.data.coverage.grid.GridCoverageReader;
> > import org.geotools.gce.geotiff.GeoTiffFormat;
> > import org.geotools.gce.geotiff.GeoTiffReader;
> > import org.geotools.gce.geotiff.GeoTiffWriter;
> > import org.geotools.geometry.DirectPosition2D;
> > import org.geotools.geometry.GeneralEnvelope;
> > import org.geotools.referencing.CRS;
> > import org.geotools.referencing.crs.DefaultGeographicCRS;
> > import org.opengis.coverage.grid.GridCoverage;
> > import org.opengis.referencing.FactoryException;
> > import org.opengis.referencing.crs.CoordinateReferenceSystem;
> > import org.opengis.referencing.operation.MathTransform;
> > import org.opengis.referencing.operation.TransformException;
> > import org.opengis.spatialschema.geometry.MismatchedDimensionException;
> >
> > import com.vividsolutions.jts.geom.Coordinate;
> >
> > public class TestGeoTIFF {
> >
> > private static void testWorks() {
> > try {
> > // Pre-requisites
> > GridCoverageFactory gcf = new GridCoverageFactory();
> > RenderedImage ri = ImageIO
> > .read(new
> > File("/home/chammack/test.tif"));
> > DirectPosition2D dp1 = new DirectPosition2D(
> > DefaultGeographicCRS.WGS84, -80, 50);
> > DirectPosition2D dp2 = new DirectPosition2D(
> > DefaultGeographicCRS.WGS84, -70, 40);
> >
> > CoordinateReferenceSystem crs1 =
> > CRS.decode("EPSG:3033");
> > MathTransform mt = CRS.findMathTransform(
> > DefaultGeographicCRS.WGS84, crs1,
> > true);
> >
> > GeneralEnvelope ge = new GeneralEnvelope(2);
> > ge.setCoordinateReferenceSystem(crs1);
> > ge.add(mt.transform(dp1, new DirectPosition2D()));
> > ge.add(mt.transform(dp2, new DirectPosition2D()));
> >
> > GridCoverage2D gc1 = gcf.create("test", ri, ge);
> >
> > File f = new File("/home/chammack/geotiff1.tif");
> > GeoTiffWriter gtw = new GeoTiffWriter(f);
> > gtw.write(gc1, null);
> >
> > GeoTiffReader gr = new GeoTiffReader(f, null);
> > GridCoverage gc2 = gr.read(null);
> >
> > System.out.println("Test1: Success!");
> >
> > } catch (MismatchedDimensionException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IllegalArgumentException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IndexOutOfBoundsException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IOException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (FactoryException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (TransformException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > }
> > }
> >
> >
> > private static void testFails() {
> > try {
> >
> > String wkt = "PROJCS[\"Lambert Conformal\",
> > GEOGCS[\"WGS84\",
> > DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563],
> > TOWGS84[0,0,0]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",
> > 0.017453292519943295], AXIS[\"Geodetic longitude\", EAST],
> > AXIS[\"Geodetic latitude\", NORTH]],
> > PROJECTION[\"Lambert_Conformal_Conic_2SP\"],
> > PARAMETER[\"central_meridian\", -95.0],
> > PARAMETER[\"latitude_of_origin\", 25.0],
> > PARAMETER[\"standard_parallel_1\", 25.0], PARAMETER[\"false_easting\",
> > 0.0], PARAMETER[\"false_northing\", 0.0],
> > PARAMETER[\"standard_parallel_2\", 25.0], UNIT[\"m\", 1.0],
> > AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]";
> >
> > // Pre-requisites
> > GridCoverageFactory gcf = new GridCoverageFactory();
> > RenderedImage ri = ImageIO
> > .read(new
> > File("/home/chammack/test.tif"));
> > DirectPosition2D dp1 = new DirectPosition2D(
> > DefaultGeographicCRS.WGS84, -80, 50);
> > DirectPosition2D dp2 = new DirectPosition2D(
> > DefaultGeographicCRS.WGS84, -70, 40);
> >
> > CoordinateReferenceSystem crs1 = CRS.parseWKT(wkt);
> > MathTransform mt = CRS.findMathTransform(
> > DefaultGeographicCRS.WGS84, crs1,
> > true);
> >
> > GeneralEnvelope ge = new GeneralEnvelope(2);
> > ge.setCoordinateReferenceSystem(crs1);
> > ge.add(mt.transform(dp1, new DirectPosition2D()));
> > ge.add(mt.transform(dp2, new DirectPosition2D()));
> >
> > GridCoverage2D gc1 = gcf.create("test", ri, ge);
> >
> > File f = new File("/home/chammack/geotiff1.tif");
> > GeoTiffWriter gtw = new GeoTiffWriter(f);
> > gtw.write(gc1, null);
> >
> > GeoTiffReader gr = new GeoTiffReader(f, null);
> > GridCoverage gc2 = gr.read(null);
> > System.out.println("Test2: Success!");
> >
> > } catch (MismatchedDimensionException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IllegalArgumentException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IndexOutOfBoundsException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (IOException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (FactoryException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > } catch (TransformException e) {
> > // TODO Auto-generated catch block
> > e.printStackTrace();
> > }
> > }
> >
> >
> > public static void main(String[] args) {
> >
> > testWorks();
> > testFails();
> > }
> > }
> >
> >
> >
> >
> >
> >
> >
> > > CIao Christopher,
> > > sorry for the delya of this answer but I have been travelling around
> > > quite a lot lately.
> > >
> > > The GeoTiffWriter is able to encode custom projections, using (almost)
> > > any CoordinateReferenceSystem you are using.
> > >
> > > Could you please provide an isolated test case to show where you are
> > > encountering problems?
> > >
> > > Simone.
> > >
> > > On 11/1/06, Christopher Hammack <[EMAIL PROTECTED]> wrote:
> > >> I am using the 2.3M0 binary build, and have been unable to write a
> > >> GeoTIFF
> > >> that does not have an EPSG code associated with it.
> > >>
> > >> For Example: Construct a grid coverage using EPSG:3033, use
> > >> GeoTIFFReader
> > >> to open it, and it works fine.
> > >>
> > >> Take the EPSG3033 WKT from the epsg.properties file, remove the EPSG
> > >> code
> > >> off the end and construct the CRS by using CRS.parse(...); Open the
> > >> resulting GeoTIFF using GeoTIFFReader and the following happens:
> > >>
> > >> java.lang.NullPointerException
> > >> at
> > >> org.geotools.gce.geotiff.GeoTiffException.getMessage(GeoTiffException.java:202)
> > >> at
> > >> org.geotools.data.DataSourceException.<init>(DataSourceException.java:47)
> > >> at
> > >> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:211)
> > >> at
> > >> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:194)
> > >>
> > >>
> > >> Is the GeoTIFF writer designed in such a way that it can only encode
> > >> EPSG
> > >> codes in, rather than custom projections?
> > >>
> > >>
> > >>
> > >>
> > >> -------------------------------------------------------------------------
> > >> Using Tomcat but need to do more? Need to support web services,
> > >> security?
> > >> Get stuff done quickly with pre-integrated technology to make your job
> > >> easier
> > >> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > >> Geronimo
> > >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > >> _______________________________________________
> > >> Geotools-gt2-users mailing list
> > >> [email protected]
> > >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> > >>
> > >
> > >
> > > --
> > > -------------------------------------------------------
> > > Eng. Simone Giannecchini
> > > President /CEO GeoSolutions
> > >
> > > http://www.geo-solutions.it
> > >
> > > -------------------------------------------------------
> > >
> > >
> >
> >
> >
>
>
> --
> -------------------------------------------------------
> Eng. Simone Giannecchini
> President /CEO GeoSolutions
>
> http://www.geo-solutions.it
>
> -------------------------------------------------------
>
--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions
http://www.geo-solutions.it
-------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users