|
From: Jody G. <jod...@gm...> - 2011-03-18 10:23:17
|
Let me look in the code for everytime crs is set to null:
- reset(); // well that makes sense
- setCRS( null );
Those are the only times CRS is used.
Thinking.
SimpleFeatureTypeBuilder makes use of an AttributeTypeBuilder internally. Let us check when attributeBuilder.setCRS is called...
- add( name, binding, crs )
- crs( crs )
Looking at the internals; it is not even consistent...
- crs( crs ) - directly modifies the attributeBuilder
Time to go look at that add( name, binding ) method you are calling ...
> public void add(String name, Class binding) {
>
> AttributeDescriptor descriptor = null;
>
> attributeBuilder.setBinding(binding);
> attributeBuilder.setName(name);
>
> // check if this is the name of the default geomtry, in that case we
> // better make it a geometry type
> // also check for jts geometry, if we ever actually get to a point where a
> // feature can be backed by another geometry model (like iso), we need
> // to remove this check
> //
> if ((defaultGeometry != null && defaultGeometry.equals(name))
> || Geometry.class.isAssignableFrom(binding)) {
>
> // if no crs was set, set to the global
> if (!attributeBuilder.isCRSSet()) {
> attributeBuilder.setCRS(crs);
> }
>
> GeometryType type = attributeBuilder.buildGeometryType();
> descriptor = attributeBuilder.buildDescriptor(name, type);
> } else {
> AttributeType type = attributeBuilder.buildType();
> descriptor = attributeBuilder.buildDescriptor(name, type);
> }
>
> attributes().add(descriptor);
> }
So my take is that setCRS is "global" only used for the default geometry, or for a Geometry class:
That tends to agree with the docs:
- http://docs.geotools.org/latest/userguide/guide/library/opengis/feature.html
Can I ask you to step through the code with your IDE debugger; perhaps you can learn how it is avoiding your CRS. And email back and we can raise a Jira issue.--
Jody Garnett
On Friday, 18 March 2011 at 3:33 PM, sebdell wrote:
> Hi,
>
> I have an issue with the following code where the SimpleFeatureType schema
> CRS is being set to null even though it is being set multiple times within
> the SimpleFeatureTypeBuilder. The getFormat().getCRS() is returning a valid
> CoordinateReferenceSystem and the builder CRS value appears to be set
> correctly. This is causing the layers to draw with the incorrect CRS and
> miss-matching bounding box.
>
> Have I missed a step or am i setting the CRS incorrectly?
>
>
> SimpleFeatureType schema = null;
>
> public SimpleFeatureType getFeatureType()
> {
> if (schema == null)
> {
> SimpleFeatureTypeBuilder builder = new
> SimpleFeatureTypeBuilder();
> builder.setName(featureCode);
> builder.setCRS(getFormat().getCRS());
> builder.setDefaultGeometry(Helper.GEOM);
>
> for (AttributeInfo info : attributeInfos.values())
> {
> builder.nillable(info.isMandatory());
> builder.minOccurs(info.isMandatory() ? 0 : 1);
> builder.maxOccurs(1);
> builder.crs(getFormat().getCRS());
>
> if (info.getShortName().equals(Helper.GEOM))
> {
> builder.add(info.getShortName(), info.getBinding(),
> getFormat().getCRS());
> }
> else
> {
> builder.add(info.getShortName(), info.getBinding());
> }
> }
>
> schema = builder.buildFeatureType();
> }
>
> return schema;
> }
>
>
> Regards,
>
> Shaun
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/SimpleFeatureType-CRS-being-set-to-null-tp6183478p6183478.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> Geotools-gt2-users mailing list
> Geo...@li...
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
|