Justin Deoliveira a écrit :
> Hi Robert,
>   
Hi,
> The way we associate srs information with a geometry is with
> Geometry.getUserData()/setUserData(). Its not ideal but JTS does not
> give us a better way to store srs information with a geometry beyond the
> srid.
>
> So here is how you can do it:
>
> //the geometry
> Geometry g = ...;
>
> //crab a crs object
> CoordinateReferenceSystem crs = CRS.decode( "EPSG:4326" );
> g.setUserData( crs );
>
> //encode...
>
> However this brings up a reasonable point. That if no user data is set
> perhaps the encode should use Goemetry.getSRID().
>
> Let me know if that works for you.
>   
Yes, it's working. Thanks you ! I get :
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#27700"; 
xmlns:gml="http://www.opengis.net/gml"; 
xmlns:xlink="http://www.w3.org/1999/xlink";>
<gml:coord><gml:X>278415.0</gml:X><gml:Y>187644.0</gml:Y></gml:coord>
</gml:Point>

The SRS format is different from what I saw but I think it's ok.
EPSG:27700 is the same SRS that osgb:BNG

The answer of the server is :
<gml:Polygon xmlns:gml="http://www.opengis.net/gml"; srsName="osgb:BNG">
        <gml:outerBoundaryIs>
            <gml:LinearRing>
                <gml:coordinates>
278414.650,187643.450 278417.550,187644.600 278420.250,187645.500 
278427.300,187647.950 278430.250,187648.950 278434.250,187650.300 
278438.850,187651.900 278436.400,187659.350 278431.650,187657.800 
278433.550,187652.050 278424.200,187649.000 278423.350,187651.700 
278425.350,187652.350 278424.350,187655.450 278421.900,187654.650 
278407.350,187649.900 278407.650,187647.800 278408.600,187641.500 
278414.650,187643.450 </gml:coordinates>
            </gml:LinearRing>
        </gml:outerBoundaryIs>
    </gml:Polygon>

When I parse this GML fragment :
FeatureCollection featureCollection = DefaultFeatureCollections
                        .newCollection();
org.geotools.xml.Configuration configuration = new 
org.geotools.gml2.GMLConfiguration();
configuration.getProperties().add(
                        Parser.Properties.IGNORE_SCHEMA_LOCATION);
configuration.getProperties().add(
                        Parser.Properties.PARSE_UNKNOWN_ELEMENTS);
org.geotools.xml.Parser parser = new org.geotools.xml.Parser(
                        configuration);
Object obj = parser.parse(pis);
the parse method raises :

java.lang.RuntimeException: Parsing failed for Polygon: 
org.opengis.referencing.NoSuchAuthorityCodeException: L'autorité "OSGB" 
n'est pas connue ou ne correspond pas aux indices spécifiés. Le fichier 
JAR qui la définie n'est peut-être pas accessible?
    at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:145)
    at 
org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:197)
    at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:163)
    at 
org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:220)
    at 
org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:497)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
Source)

([...].NoSuchAuthorityCodeException: The authority "OSGB" is not known 
or doesn't match to the specified indexis. The JAR file which defined it 
may not be reached ?)

So I must define this OSGB Authority which is exactly the same that 
EPSG:27700

I tried that :
Hints hints = new Hints(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY,             
                   
                    
"E:\\eclipse\\eclipse_3.3\\workspace\\com.anwrt.xqueryengine");
AuthorityFactory authority = new FactoryUsingWKT(hints);
FactoryFinder.addAuthorityFactory(authority);
but it doesn't work. How can I specify a new authority osgb ? Is It 
possible to specify it from an old one ?

Thanks for your help.
Regards,

-- 
Robert JACOLIN
M2M
ANYWARE TECHNOLOGIES
Tél : +33 (0)5.61.00.06.56
Fax : +33 (0)5 61 00 51 46
www.anyware-tech.com


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to