Class GeojsonTableBuilder

java.lang.Object
uk.ac.starlink.ttools.example.GeojsonTableBuilder
All Implemented Interfaces:
uk.ac.starlink.table.TableBuilder

public class GeojsonTableBuilder extends Object implements uk.ac.starlink.table.TableBuilder
Experimental GeoJSON table input handler. It was written with reference to RFC7946 and a countries.geojson file I found, but it's pretty scrappy. It looks for a type="FeatureCollection" entry in the top-level object, and then pulls Features out of that, currently taking account of only Polygon and MultiPolygon types. Winding directions and exclusions are currently ignored. Polygons are turned into STC-S POLYGON or UNION of POLYGON entries, and the other metadata items are stored in their own columns. The whole GeoJSON input file is slurped into memory, even in streaming mode.
Since:
3 Jun 2020
Author:
Mark Taylor
  • Constructor Details

    • GeojsonTableBuilder

      public GeojsonTableBuilder()
      Default constructor.
  • Method Details

    • canImport

      public boolean canImport(DataFlavor flavor)
      Specified by:
      canImport in interface uk.ac.starlink.table.TableBuilder
    • getFormatName

      public String getFormatName()
      Specified by:
      getFormatName in interface uk.ac.starlink.table.TableBuilder
    • looksLikeFile

      public boolean looksLikeFile(String location)
      Specified by:
      looksLikeFile in interface uk.ac.starlink.table.TableBuilder
    • makeStarTable

      public uk.ac.starlink.table.StarTable makeStarTable(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy storage) throws IOException
      Specified by:
      makeStarTable in interface uk.ac.starlink.table.TableBuilder
      Throws:
      IOException
    • streamStarTable

      public void streamStarTable(InputStream in, uk.ac.starlink.table.TableSink sink, String pos) throws IOException
      Specified by:
      streamStarTable in interface uk.ac.starlink.table.TableBuilder
      Throws:
      IOException
    • setShapeColName

      public void setShapeColName(String shapeColName)
      Sets the name for the feature shape column.
      Parameters:
      shapeColName - name for STC-S feature shape column
    • getShapeColName

      public String getShapeColName()
      Returns the name of the feature shape column.
      Returns:
      name for STC-S feature shape column