kiwi-postgis  Version 0.1.0.0
JtsPolyshapeWriter Class Reference
Inheritance diagram for JtsPolyshapeWriter:
Collaboration diagram for JtsPolyshapeWriter:

Public Member Functions

void write (Encoder output, Geometry geom) throws IOException
 
String getFormatName ()
 
void write (Writer output, Geometry shape) throws IOException
 
String toString (Geometry shape)
 

Static Public Attributes

static final char KEY_POINT = '0'
 
static final char KEY_LINE = '1'
 
static final char KEY_POLYGON = '2'
 
static final char KEY_MULTIPOINT = '3'
 
static final char KEY_CIRCLE = '4'
 
static final char KEY_BOX = '5'
 
static final char KEY_ARG_START = '('
 
static final char KEY_ARG_END = ')'
 
static final char KEY_SEPERATOR = ' '
 

Protected Member Functions

void write (Encoder output, CoordinateSequence coordseq) throws IOException
 
void write (Encoder output, Coordinate[] coord) throws IOException
 
void write (Encoder output, Polygon p) throws IOException
 

Member Function Documentation

◆ getFormatName()

String getFormatName ( )
inherited
50  {
51  return "PolyShape";
52  }

◆ toString()

String toString ( Geometry  shape)
inherited

References PolyshapeWriter.write().

Referenced by PolyshapeDatatype.unparse().

131  {
132  try {
133  StringWriter buffer = new StringWriter();
134  write(buffer, shape);
135  return buffer.toString();
136  } catch (IOException ex) {
137  throw new RuntimeException(ex);
138  }
139  }
void write(Writer output, Geometry shape)
Definition: PolyshapeWriter.java:56

◆ write() [1/5]

void write ( Encoder  output,
CoordinateSequence  coordseq 
) throws IOException
protected

Referenced by JtsPolyshapeWriter.write().

20  {
21  int dim = coordseq.getDimension();
22 // if(dim>2) {
23 // throw new IllegalArgumentException("only supports 2d geometry now ("+dim+")");
24 // }
25  for (int i = 0; i < coordseq.size(); i++) {
26  output.write(coordseq.getOrdinate(i, 0),
27  coordseq.getOrdinate(i, 1));
28  }
29  }

◆ write() [2/5]

void write ( Encoder  output,
Coordinate []  coord 
) throws IOException
protected
31  {
32  for (int i = 0; i < coord.length; i++) {
33  output.write(coord[i].x, coord[i].y);
34  }
35  }

◆ write() [3/5]

void write ( Encoder  output,
Polygon  p 
) throws IOException
protected

References PolyshapeWriter.KEY_POLYGON, and JtsPolyshapeWriter.write().

37  {
38  output.write(PolyshapeWriter.KEY_POLYGON);
39  write(output, p.getExteriorRing().getCoordinateSequence());
40  for (int i = 0; i < p.getNumInteriorRing(); i++) {
41  output.startRing();
42  write(output, p.getInteriorRingN(i).getCoordinateSequence());
43  }
44  }
void write(Encoder output, CoordinateSequence coordseq)
Definition: JtsPolyshapeWriter.java:20

◆ write() [4/5]

void write ( Encoder  output,
Geometry  geom 
) throws IOException

References PolyshapeWriter.KEY_LINE, PolyshapeWriter.KEY_MULTIPOINT, PolyshapeWriter.KEY_POINT, and JtsPolyshapeWriter.write().

46  {
47  if (geom instanceof Point) {
48  Point v = (Point) geom;
49  output.write(PolyshapeWriter.KEY_POINT);
50  write(output, v.getCoordinateSequence());
51  return;
52  } else if (geom instanceof Polygon) {
53  write(output, (Polygon) geom);
54  return;
55  } else if (geom instanceof LineString) {
56  LineString v = (LineString) geom;
57  output.write(PolyshapeWriter.KEY_LINE);
58  write(output, v.getCoordinateSequence());
59  return;
60  } else if (geom instanceof MultiPoint) {
61  MultiPoint v = (MultiPoint) geom;
62  output.write(PolyshapeWriter.KEY_MULTIPOINT);
63  write(output, v.getCoordinates());
64  return;
65  } else if (geom instanceof GeometryCollection) {
66  GeometryCollection v = (GeometryCollection) geom;
67  for (int i = 0; i < v.getNumGeometries(); i++) {
68  if (i > 0) {
69  output.seperator();
70  }
71  write(output, v.getGeometryN(i));
72  }
73  } else {
74  throw new UnsupportedOperationException("unknown: " + geom);
75  }
76  }
void write(Encoder output, CoordinateSequence coordseq)
Definition: JtsPolyshapeWriter.java:20

◆ write() [5/5]

void write ( Writer  output,
Geometry  shape 
) throws IOException
inherited

Referenced by PolyshapeWriter.toString().

56  {
57  if (shape == null) {
58  throw new NullPointerException("Shape can not be null");
59  }
60  write(new Encoder(output), shape);
61  }
void write(Writer output, Geometry shape)
Definition: PolyshapeWriter.java:56

Member Data Documentation

◆ KEY_ARG_END

final char KEY_ARG_END = ')'
staticinherited

Referenced by PolyshapeReader.read().

◆ KEY_ARG_START

final char KEY_ARG_START = '('
staticinherited

Referenced by PolyshapeReader.read().

◆ KEY_BOX

final char KEY_BOX = '5'
staticinherited

◆ KEY_CIRCLE

final char KEY_CIRCLE = '4'
staticinherited

Referenced by PolyshapeReader.read().

◆ KEY_LINE

final char KEY_LINE = '1'
staticinherited

◆ KEY_MULTIPOINT

final char KEY_MULTIPOINT = '3'
staticinherited

◆ KEY_POINT

final char KEY_POINT = '0'
staticinherited

◆ KEY_POLYGON

final char KEY_POLYGON = '2'
staticinherited

◆ KEY_SEPERATOR

final char KEY_SEPERATOR = ' '
staticinherited

Referenced by PolyshapeReader.read().