Please go ahead with the fix, now that GeoServer has the ability to redefine schema attributes (and I hope to add the ability to edit title / abstract) this information will be more widely used and relied on.
Jody On Wed, May 25, 2022 at 11:32 PM Roar Brænden <roar.brenden...@gmail.com> wrote: > Hi, > > I was reading some shapefiles when it came to my attention that something > was strange with the schema's reported: > > TS14_max identified extends > polygonFeature(the_geom:MultiPolygon,ID1:ID1,AV_Time:AV_Time,Shape_Leng:Shape_Leng,Shape_Area:Shape_Area) > TS21_min identified extends > polygonFeature(the_geom:MultiPolygon,ID1:ID1,AV_Time:AV_Time,Shape_Leng:Shape_Leng,Shape_Area:Shape_Area) > TS16_mc identified extends > polygonFeature(the_geom:MultiPolygon,ID1:ID1,AV_Time:AV_Time,Shape_Leng:Shape_Leng,Shape_Area:Shape_Area) > > The problem is why does it repeat the name of the fields. After some > digging in the code, I realized that the problem is within: > org.geotools.feature.AttributeTypeBuilder.buildDescriptor(String name) > > public AttributeDescriptor buildDescriptor(String name) { > setName(name); <---- name isn't the type's name. > It's the attributes name > if (binding == null) > throw new IllegalStateException("No binding has been provided > for this attribute"); > if (crs != null || Geometry.class.isAssignableFrom(binding)) { > return buildDescriptor(name, buildGeometryType()); > } else { > return buildDescriptor(name, buildType()); > } > } > > According to Github that code hasn't been changed for years, so GeoTools > users must have become familiar with this "problem". Because it might not > be a real problem. I do believe most people are using getBinding() rather > than looking at what is returned by getName() when looking at an > AttributeType. > > I'm quite sure removing that setName(name) line will fix the problem, but > doing so will possibly end up in a lot of unit test failures like this one: > > [ERROR] ImageMosaicReaderTest.granuleSourceTest:1437 > expected:<...ltiPolygon,location:[location,time:time,endtime:endtime,date:date,lowz:lowz,highz:highz,loww:loww,highw:highw])> > but > was:<...ltiPolygon,location:[String,time:Date,endtime:Date,date:String,lowz:Integer,highz:Integer,loww:Integer,highw:Integer])> > > > Should I go forward fixing this, or are people so used to this that they > don't bother? > > Best regards, > Roar Brænden > > _______________________________________________ > GeoTools-Devel mailing list > GeoTools-Devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel > -- -- Jody Garnett
_______________________________________________ GeoTools-Devel mailing list GeoTools-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel