Hello Adrian

Adrian Custer a écrit :
> You're going to have to walk me through this step by step. I've hit my
> head against the wall too much and I'm ready to give up. 

I'm sorry for that... I realize that I wrote way too few documentation for the 
referencing module. 
Please have no hesitation to ask me instead of consuming too much time on 
issues.

> 1) Make a ParameterValueGroup using a magic_string:
>   pg = mathTransformFactory.getDefaultParameters("Mercator_1SP");
> 
> A? Do we get a list of all the possible magic_strings for the
> ParameterValue Groups from the main() method in
> DefaultMathTransformFactory with parameter '-all'? 

Yes. Option "-all" will list the magic strings for every math transforms. If 
you want only the magic 
strings (parameter names) for one specific math transform, e.g. "Mercator_1SP", 
give that specific 
math transform name instead.

Note: the magic strings are not Geotools specific. One of our main source is 
the following site 
(giving directly the URL to the "Mercator_1SP" projection, but other pages like 
this one exist for 
most projections):

     http://www.remotesensing.org/geotiff/proj_list/mercator_1sp.html

Note that more than one "magic string" may exist for the same thing. For 
example "Mercator_1SP" is 
the OGC name, but GeoTIFF calls the same thing as "CT_Mercator". Geotools will 
understand both. I 
mean, "Mercator_1SP" and "CT_Mercator" are synonymous (aliases) for Geotools. 
Same applies to 
projection parameters listed in the above-cited page: "NatOriginLat" and 
"latitude_of_origin" are 
synonymous for Geotools.

Note (just for information, most users can ignore that): a name can optionally 
be prefixed by its 
name space, which will be verified. "Mercator_1SP", "OGC:Mercator_1SP", 
"CT_Mercator" and 
"GeoTIFF:CT_Mercator" are all legal names. But "OGC:CT_Mercator" and 
"GeoTIFF:Mercator_1SP" are 
illegal and will be rejected by Geotools. This mean that users can prefix a 
name by "OGC:" (for 
example) if they want to be sure that a name is an OGC name, not a GeoTIFF one.

The following command

    java org.geotools.referencing.operation.DefaultTransformFactory Mercator_1SP

should list magic strings understood by Geotools for the "Mercator_1SP" 
projection. Every aliases 
should be listed as well. Actually, the output of the above-cited command 
should be pretty similar 
to the table in the above-cited internet link.

Magic strings are expected by three WKT elements: PROJECTION["Mercator_1SP"] or 
PARAM_MT["Mercator_1SP"] (where "Mercator_1SP" is just an example) and 
PARAMETER["latitude_of_origin", 0] (where "latitude_of_origin" is just an 
example). No WKT element 
other than PROJECTION, PARAM_MT and PARAMETER come to my mind right now. For 
all other WKT elements, 
the name is just an arbitrary name and can be whatever the user which.

We can see PROJECTION as a special way to describe a PARAM_MT (MathTransform) 
inside a PROJCS 
(ProjectedCRS) definition.

Lets also keep in mind that in the special case of DATUM, Geotools will 
consider two Datum object as 
equivalent only if they share the same name (or at least one alias). For all 
other objects, Geotools 
will inspect the Object properties instead. For example for a 
CoordinateReferenceSystem, Geotools 
will compare the CoordinateSystem and all axis - the name is considered as a 
metadata and ignored by 
CRS.compareIgnoreMetadata(...). But for the special case of Datum, the name is 
the only property we 
can use in order to determine if two Datum are equivalent or not. For this 
reason, Datum name are 
considered as a fundamental property, not a metadata we can ignore. This is why 
Datum names are more 
important than the name of other referencing object, and why Geotools maintains 
a list of Datum aliases:

http://svn.geotools.org/geotools/trunk/gt/module/referencing/src/org/geotools/referencing/factory/DatumAliasesTable.txt

Why it is important to decide if two Datum object are equal or not? Because if 
a CoordinateOperation 
is requested between two CRS, and if Datum of those two CRS are considered 
different, then Geotools 
will attempt a datum shift, which requires Bursa-Wolf parameters (the TOWGS84 
element in WKT).

Note that Datum names are important only when comparing two Datum objects. At 
the opposite of 
MathTransform names, this is not a "magic string" selecting the algorithm to be 
used for some 
processing.

Just for reference: WKT specification is there:

http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html



> B? The values are being obtained from the EPSG database?

Yes, exactly. Or specified by PARAMETER elements in WKT format, or by calls to 
group.parameter("magic_name").setValue(someValue);


> C? How do we know what parameters are going to be in the group returned?
> Again from the list in the main() method? 

Yes. Or from the above-cited link (copying the link there, pointing to all 
projections). Note 
however that Geotools do not yet implements all projections listed there; the 
main() method lists 
the projections actually implemented.

     http://www.remotesensing.org/geotiff/proj_list/

Users can also get this list programmatically. Example:

     pg = mathTransformFactory.getDefaultParameters("Mercator_1SP");
     ParameterDescriptorGroup dg = pg.getDescriptor();
     for (GeneralParameterDescriptor descriptor : dg.descriptors()) {
         System.out.println(descriptor.getName().getCode());
     }



> 2) If needed, change the parameters in the ParameterValueGroup
>   pg.parameter("falseEasting").setValue(...);
> 
> C? How do we know what the valid values are for each parameter? 

The DefaultMathTransformFactory main() method should list the minimum and 
maximum values. User can 
also get more information programmatically as below:

     ParameterDescriptorGroup dg = pg.getDescriptor();
     ParameterDescriptor descriptor = (ParameterDescriptor) 
pg.descriptor("false_easting");

  or (may be more convenient and avoid a cast):

     Parameter p = pg.parameter("false_easting");
     ParameterDescriptor descriptor = pg.getDescriptor();

then:

     if (descriptor.getMinimumOccurs() == 0) {
         // This parameter is optional
     } else {
         // This parameter is mandatory
     }
     Set<Object> values = descriptor.getValidValues();
     if (values != null) {
         // This parameter is restricted to a set of valid values...
         if (!values.contains(myValue)) {
             // ... and my value is not one of those valid values.
         }
     }
     Comparable min = descriptor.getMinimumValue();
     if (min != null) {
         // This parameter is restricted to a minimal value...
         if (min.compareTo(myValue) > 0) {
             // ... and my value is greater than the minimal value.
         }
     }
     // etc.




> 3) Make a DefiningConversion which requires:
>   String name : 
>   ParameterValueGroup:  generated above

Yes.


> D? Is the name arbitrary or from some list somewhere?

Arbitrary. The only place where the name is significant is:

   - MathTransform (or ParameterGroup for a MathTransform) and its Parameters;
     The MathTransform name is a magic string which determine the algorithm 
being
     used. Parameter names are magic string as well.

   - Datum (significant only when comparing two datums for determining
     if a "datum shift" is required or not during a coordinate operation).



> 5) Make a Map for the projectedCRS's properties.
> 
> E? What's supposed to be in this Map? A name presumably, but is there
> other stuff? Is the name arbitrary?

Yes. The Map must constain at least the name. All other properties are 
optional. The Map keys are 
listed as IdentifiedObject constants:

http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/IdentifiedObject.html#field_summary

More specific keys are defined in some subinterfaces, for example:

http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/ReferenceSystem.html#field_summary

Example:

     Map properties = new HashMap();
     properties.put(IdentifiedObject.NAME_KEY, "My arbitrary name"); // 
Mandatory
     properties.put(ReferenceSystem.VALID_AREA_KEY, myValidArea);    // Optional

As a rule of thumb, the Map contains all metadata. Everything specified in this 
map, no matter which 
"createFoo(...)" method is invoked (except Datum and subtype) is ignored by 
CRS.equalsIgnoreMetadata(...). This include the name, valid area, scope, etc. 
Everything not 
specified in this map is taken in account by CRS.equalsIgnoreMetadata(...). 
This includes the 
coordinate system axis, etc. Let remind that Datum name and aliases are the 
only exception to the 
above-cited rule.

Optional note: some properties can be localized, e.g.:

    properties.put(IdentifiedObject.REMARKS_KEY,         "My remarks");     // 
Default language
    properties.put(IdentifiedObject.REMARKS_KEY + "_en", "My remarks");     // 
English
    properties.put(IdentifiedObject.REMARKS_KEY + "_fr", "Mes remarques");  // 
French

The above is actually just a convenient way to create an InternationalString. 
Geotools will assemble 
the above lines in a single InternationalString for us.


> 6) Create the ProjectedCRS using the FactoryGroup's convenience method
> and all the pieces above.
> 
> is that right?

Right :)

        Martin.

-------------------------------------------------------------------------
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

Reply via email to