Thanks Adrian - I'll take a look at this.
Amy
Adrian Custer wrote:
> On Mon, 2007-01-08 at 19:57 -0900, Amy Johnson wrote:
>
>> Adrian,
>>
>> I was switching over to 2.3 and trying to update my existing code to
>> remove any deprecated methods. I'm actually using Java 1.4 and all I'm
>> trying to do right now is figure out how to instantiate a
>> CoordinateReferenceSystem.
>>
>> Regards,
>>
>> Amy
>>
>
> For instantiation, you need geotools. The typical way is to make one
> from an authority factory. I don't have an example under my thumb.
> You'll have to poke around for the methods. you'll also need one of the
> *epsg plugins on your classpath.
>
> To make them yourself, see the demo/introduction code for the following:
>
>
> Pre-made CRS:
> ------------
>
> org.geotools.referencing.crs.DefaultGeographicCRS.WGS84
>
>
>
> Making a CRS from another:
> -------------------------
>
> /*
> * Create a Mercator ProjectedCRS from DefaultGeogCRS.
> */
> public void create_ProjectedCRS_from_DefaultGeogCRS(){
>
> demoGUI.textArea.append("Start: Create ProjectedCRS from
> DefaultGeographicCRS.\n");
>
> /* Properties of the Projected CRS */
> Map props = new HashMap();
> props.put(IdentifiedObject.NAME_KEY, "My arbitrary name"); //
> Mandatory
> // props.put(ReferenceSystem.VALID_AREA_KEY,e); // Optional
>
>
> /* Geographic CoordinateReferenceSystem */
> //TODO: this is hard coded below because the compiler doesn't
> work.
> CoordinateReferenceSystem geogCRS =
> org.geotools.referencing.crs.DefaultGeographicCRS.WGS84;
>
>
> /* Defining Conversion: Name, Parameters */
> final String dcName = "A Mercator";
> /* Parameters for the Mercator */
> DefaultMathTransformFactory mtf = new
> DefaultMathTransformFactory();
> ParameterValueGroup pvg = null;
> try {
> pvg = mtf.getDefaultParameters("Mercator_1SP");
> } catch (NoSuchIdentifierException nsiex){
> System.err.println("On DefaultPrameterGroup creation: "+
> nsiex.getMessage());
> }
> //Start Test Output
> // ParameterDescriptorGroup dg = pvg.getDescriptor()
> // for (GeneralParameterDescriptor descriptor :
> dg.descriptors()) {
> // System.out.println(descriptor.getName().getCode());
> // }
> //End Test Output
> DefiningConversion dc = new DefiningConversion(dcName,pvg);
> //TODO: Added to make the compiler happy, could merge with
> above.
> Conversion c = (Conversion) dc;
>
>
>
> /* Coordinate System */
> Map map = new HashMap();
> CSFactory csFactory = FactoryFinder.getCSFactory(null);
> CoordinateSystemAxis xAxis = null;
> CoordinateSystemAxis yAxis = null;
> CartesianCS worldCS = null;
> try {
> map.clear();
> map.put("name", "Cartesian X axis");
> xAxis = csFactory.createCoordinateSystemAxis(map, "X",
> AxisDirection.EAST, SI.METER);
> map.clear();
> map.put("name", "Cartesian Y axis");
> yAxis = csFactory.createCoordinateSystemAxis(map, "Y",
> AxisDirection.NORTH, SI.METER);
> map.clear();
> map.put("name", "Cartesian CS");
> worldCS = csFactory.createCartesianCS(map, xAxis, yAxis);
> } catch (FactoryException fex) {
> System.err.println("On cartesianCS creation: " +
> fex.getMessage());
> }
>
> /* Projected CRS */
> FactoryGroup fg = new FactoryGroup(null);
> try{
> projCRS = fg.createProjectedCRS(props,
>
> org.geotools.referencing.crs.DefaultGeographicCRS.WGS84,
> c,
> worldCS);
> // //TODO: figure out why this breaks but above works.
> // projCRS = fg.createProjectedCRS(props,
> // geogCRS,
> // dc,
> // worldCS);
> } catch (FactoryException fex) {
> System.err.println("On projectedCRS creation: " +
> fex.getMessage());
> }
> // System.out.println(projCRS.toWKT())
>
>
> I don't yet have a 'make a CRS completely from scratch'.
>
> hope that helps
> --adrian
>
>
>> Adrian Custer wrote:
>>
>>> Hey Amy,
>>>
>>> The right GeoAPI javadocs (and the server) depend on what version of the
>>> library you are using or, on the version of Geotools you care about. And
>>> I can't keep them all strait so I can't answer you exactly.
>>>
>>> Older Geotools use GeoAPI 2.0, for which you have found the Javadocs.
>>> Geotools 2.3 uses a particular snapshot of the GeoAPI library and, even
>>> worse, uses the version for Java 1.4 without Generics. Then there is
>>> GeoAPI trunk if you are hacking GeoAPI. All very complex.
>>>
>>> You might try:
>>> http://geoapi.sourceforge.net/pending/javadoc/
>>> or let us know what version you are targeting ( of geoapi or geotools)
>>> and we'll try to answer better.
>>>
>>> --adrian
>>>
>>>
>>> On Mon, 2007-01-08 at 13:07 -0900, Amy Johnson wrote:
>>>
>>>
>>>> Hello:
>>>>
>>>> I'm trying to figure out where the most current documentation for
>>>> org.opengis resides. I'm specifically looking for documentation on
>>>> org.opengis.referencing.crs.CoordinateReferenceSystem, but it would be
>>>> good to know where it all is. I did a search, but it returned the
>>>> following page:
>>>>
>>>> http://geoapi.sourceforge.net/2.0/javadoc/org/opengis/referencing/crs/CoordinateReferenceSystem.html
>>>>
>>>> with a date of 2005-06-08, which seems a little old. Can anyone point me
>>>> to the correct Javadocs?
>>>>
>>>> Regards,
>>>>
>>>> Amy
>>>>
>>>> -------------------------------------------------------------------------
>>>> Take Surveys. Earn Cash. Influence the Future of IT
>>>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>>>> your
>>>> opinions on IT & business topics through brief surveys - and earn cash
>>>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>>> _______________________________________________
>>>> Geotools-gt2-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>>>
>>>>
>>>
>>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share your
>> opinions on IT & business topics through brief surveys - and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users