That's probably my fault :-) GeoJSON parsing has moved to gt-geojson-core which along with the gt-geojson-store replaces the functionality in gt-geojson. The plan is at some point in the future to remove gt-geoson but currently GeoServer makes use of it (at least I think that was the problem) and I ran out of time and energy,
With gt-geoson-core you should be able to do something like this: GeometryFactory gf = new GeometryFactory(); SimpleFeatureType type = DataUtilities.createType("test", "the_geom:Point:srid=4326"); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); builder.add(gf.createPoint(new Coordinate(1.23456789, 0.123456789))); SimpleFeature feature = builder.buildFeature(null); ByteArrayOutputStream out = new ByteArrayOutputStream(); GeoJSONWriter writer = new GeoJSONWriter(out); writer.setMaxDecimals(6); writer.write(feature); Ian On Thu, 16 May 2024 at 05:56, Phil Scadden <p.scad...@gns.cri.nz> wrote: > Ultimately, what I am trying to do is read some features from a geopkg > using geotools, fidding with contents of the feature and then writing the > Feature to an ESRI FeatureServer using the REST API. Along the way, I have > to get the geotools geometry converted to an ESRI Geometry class. > > The ESRI OGCGeometry (https://esri.github.io/geometry-api-java > <https://esri.github.io/geometry-api-java%20can> can convert to ESRI > geometry, but the fromGeoJson seems to be only method for creating a > OGCGeometry. > > > > What I am struggling with is getting a GeoJSON string out of geotools. I > added gt-geojson module but can only see method for writing to file. Am I > missing something blindingly obvious here? The documentation doesn’t seem > up to date – pointing to methods that (eg GeoJSONWriter) that don’t exist > (and pages 404 in the Javadoc). > > > > Using 31.0 > > > > Also looking at option of using a WKT route instead. > > > > > > ________________________________________________ > > Ngā mihi, Nā Phil Scadden (he/him) > > Te Raraunga me te Tātaritanga Mokowā Aronuku (Geospatial Data and > Analysis) > > *GNS Science* *Te Pῡ Ao* > > 13A Alma St, Renwick, 7204 > > New Zealand Ph +64 27 3463185 > > > > “Whāia te iti kahurangi ki te tūohu koe me he maunga teitei” > > > Notice: This email and any attachments are confidential and may not be > used, published or redistributed without the prior written consent of the > Institute of Geological and Nuclear Sciences Limited (GNS Science). If > received in error please destroy and immediately notify GNS Science. Do not > copy or disclose the contents. > _______________________________________________ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- Ian Turton
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users