Yes, that fixed the problem of invisibility. Thank you very much!
It would be interesting to know why this solved it.  
 
Best regards
 
Gesendet: Samstag, 06. Februar 2021 um 11:06 Uhr
Von: "Ian Turton" <ijtur...@gmail.com>
An: "maca delic" <macade...@gmx.de>
Cc: "geotools-users" <geotools-gt2-users@lists.sourceforge.net>
Betreff: Re: Re: [Geotools-gt2-users] GML invisible
Well this is a bit weird but after adding a background map I finally found what seems to be the problem, it's your axis order. If you add
Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);

at the top of your program it correctly draws your polygon in India. But since your coordinates are valid the other way round I can't quite see why it wouldn't draw them before.

Ian
 
On Fri, 5 Feb 2021 at 17:35, maca delic <macade...@gmx.de> wrote:
Thanks for the response, now i understand what that line does. Unfortunately removing it did not change anything. The polyong is still invisible. I also imported the same gml file into QGIS and it is working fine there.
 
Best regards
 
Gesendet: Freitag, 05. Februar 2021 um 11:20 Uhr
Von: "Ian Turton" <ijtur...@gmail.com>
An: "maca delic" <macade...@gmx.de>
Cc: "geotools-users" <geotools-gt2-users@lists.sourceforge.net>
Betreff: Re: [Geotools-gt2-users] GML invisible
I haven't tested this but I suspect that setting the else rule (`rule.setElseFilter(true);`) is the problem as it means the rule will only be executed if the filters of the other rules return false, as you only have one rule I'm not at all sure what the renderer would do (stepping through with the debugger would be the "easy" way to answer that) for the time being I'd just remove that line and see if it fixes it.
 
Ian
 
On Thu, 4 Feb 2021 at 19:33, maca delic <macade...@gmx.de> wrote:
I'm trying to parse a GML file and make it visible with GeoTools. It is imported into the MapFrame and the geometry is there, as i get information about the polygon if i click on the mappane with the InfoTool.
But it is invisible. Is this a styling problem? Or am i using the wrong aproach in general?
 
Best regards
 
File gmlFile = new File("...mypolygon_px6_gml3.1.1.gml");    
InputStream gmlInStream = new FileInputStream(gmlFile);
GML gml = new GML(Version.GML3);
SimpleFeatureCollection featureCollection = gml.decodeFeatureCollection(gmlInStream);
        
final StyleBuilder builder = new StyleBuilder();
final PolygonSymbolizer polygonSymbolize = builder.createPolygonSymbolizer(Color.RED, Color.GREEN, 1);
final Rule rule = builder.createRule(polygonSymbolize);
rule.setElseFilter(true);
final Rule rules[] = new Rule[] { rule };
final FeatureTypeStyle featureTypeStyle = builder.createFeatureTypeStyle("Feature", rules);
final Style style = builder.createStyle();
style.setName("style");
style.getDescription().setTitle("User Style");
style.getDescription().setAbstract("Definition of Style");
style.featureTypeStyles().add(featureTypeStyle);
        
FeatureLayer layer = new FeatureLayer(featureCollection, style);
MapContent mapcontent = new MapContent();
mapcontent.getViewport().setBounds(layer.getBounds());
mapcontent.addLayer(layer);
JMapFrame.showMap(mapcontent);
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users


--
Ian Turton


--
Ian Turton
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to