org.locationtech.jts.io.ParseException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.locationtech.jts.io.ParseException.<init>()方法的一些代码示例,展示了ParseException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.<init>()方法的具体详情如下:
包路径:org.locationtech.jts.io.ParseException
类名称:ParseException
方法名:<init>

ParseException.<init>介绍

[英]Creates a ParseException with es detail message.
[中]使用e的详细信息创建ParseException

代码示例

代码示例来源:origin: geotools/geotools

/**
 * Parses the next number in the stream. Numbers with exponents are handled. <tt>NaN</tt> values
 * are handled correctly, and the case of the "NaN" token is not significant.
 *
 * @param tokenizer tokenizer over a stream of text in Well-known Text format. The next token
 *     must be a number.
 * @return the next number in the stream
 * @throws ParseException if the next token is not a valid number
 * @throws IOException if an I/O error occurs
 */
private double getNextNumber() throws IOException, ParseException {
  int type = tokenizer.nextToken();
  switch (type) {
    case StreamTokenizer.TT_WORD:
      {
        if (tokenizer.sval.equalsIgnoreCase(NAN_SYMBOL)) {
          return Double.NaN;
        } else {
          try {
            return Double.parseDouble(tokenizer.sval);
          } catch (NumberFormatException ex) {
            throw new ParseException("Invalid number: " + tokenizer.sval);
          }
        }
      }
  }
  parseError("number");
  return 0.0;
}

代码示例来源:origin: geotools/geotools

private Geometry readCompoundCurve() throws IOException, ParseException {
  int numGeom = dis.readInt();
  List<LineString> geoms = new ArrayList<>();
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof LineString))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "CompoundCurve");
    geoms.add((LineString) g);
  }
  return factory.createCurvedGeometry(geoms);
}

代码示例来源:origin: geotools/geotools

/**
 * Reads a Well-Known Text representation of a {@link Geometry} from a {@link Reader}.
 *
 * @param reader a Reader which will return a <Geometry Tagged Text> string (see the OpenGIS
 *     Simple Features Specification)
 * @return a <code>Geometry</code> read from <code>reader</code>
 * @throws ParseException if a parsing problem occurs
 */
public Geometry read(Reader reader) throws ParseException {
  tokenizer = new StreamTokenizer(reader);
  // set tokenizer to NOT parse numbers
  tokenizer.resetSyntax();
  tokenizer.wordChars('a', 'z');
  tokenizer.wordChars('A', 'Z');
  tokenizer.wordChars(128 + 32, 255);
  tokenizer.wordChars('0', '9');
  tokenizer.wordChars('-', '-');
  tokenizer.wordChars('+', '+');
  tokenizer.wordChars('.', '.');
  tokenizer.whitespaceChars(0, ' ');
  tokenizer.commentChar('#');
  try {
    return readGeometryTaggedText();
  } catch (IOException e) {
    throw new ParseException(e.toString());
  }
}

代码示例来源:origin: geotools/geotools

private MultiPoint readMultiPoint() throws IOException, ParseException {
  int numGeom = dis.readInt();
  Point[] geoms = new Point[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof Point))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPoint");
    geoms[i] = (Point) g;
  }
  return factory.createMultiPoint(geoms);
}

代码示例来源:origin: geotools/geotools

private MultiPoint readMultiPoint() throws IOException, ParseException {
  int numGeom = dis.readInt();
  Point[] geoms = new Point[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof Point))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPoint");
    geoms[i] = (Point) g;
  }
  return factory.createMultiPoint(geoms);
}

代码示例来源:origin: geotools/geotools

private MultiLineString readMultiLineString() throws IOException, ParseException {
  int numGeom = dis.readInt();
  LineString[] geoms = new LineString[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof LineString))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
    geoms[i] = (LineString) g;
  }
  return factory.createMultiLineString(geoms);
}

代码示例来源:origin: geotools/geotools

private MultiLineString readMultiLineString() throws IOException, ParseException {
  int numGeom = dis.readInt();
  LineString[] geoms = new LineString[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof LineString))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
    geoms[i] = (LineString) g;
  }
  return factory.createMultiLineString(geoms);
}

代码示例来源:origin: geotools/geotools

private MultiPolygon readMultiPolygon() throws IOException, ParseException {
  int numGeom = dis.readInt();
  Polygon[] geoms = new Polygon[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof Polygon))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
    geoms[i] = (Polygon) g;
  }
  return factory.createMultiPolygon(geoms);
}

代码示例来源:origin: geotools/geotools

private MultiPolygon readMultiPolygon() throws IOException, ParseException {
  int numGeom = dis.readInt();
  Polygon[] geoms = new Polygon[numGeom];
  for (int i = 0; i < numGeom; i++) {
    Geometry g = readGeometry();
    if (!(g instanceof Polygon))
      throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
    geoms[i] = (Polygon) g;
  }
  return factory.createMultiPolygon(geoms);
}

代码示例来源:origin: geotools/geotools

/**
 * Throws a formatted ParseException for the current token.
 *
 * @param expected a description of what was expected
 * @throws ParseException
 * @throws AssertionFailedException if an invalid token is encountered
 */
private void parseError(String expected) throws ParseException {
  // throws Asserts for tokens that should never be seen
  if (tokenizer.ttype == StreamTokenizer.TT_NUMBER)
    Assert.shouldNeverReachHere("Unexpected NUMBER token");
  if (tokenizer.ttype == StreamTokenizer.TT_EOL)
    Assert.shouldNeverReachHere("Unexpected EOL token");
  String tokenStr = tokenString();
  throw new ParseException("Expected " + expected + " but found " + tokenStr);
}

代码示例来源:origin: geotools/geotools

/**
 * Creates a <code>LineString</code> using the next token in the stream.
 *
 * @return
 * @throws IOException
 * @throws ParseException
 */
private LineString readCircularStringText() throws IOException, ParseException {
  List<Coordinate> coordinates = getCoordinateList(true);
  if (coordinates.size() == 0) {
    return geometryFactory.createCurvedGeometry(
        new LiteCoordinateSequence(new Coordinate[0]));
  } else if (coordinates.size() < 3) {
    throw new ParseException("A CIRCULARSTRING must contain at least 3 control points");
  } else {
    double[] controlPoints = toControlPoints(coordinates);
    return geometryFactory.createCurvedGeometry(2, controlPoints);
  }
}

代码示例来源:origin: geotools/geotools

return readLineStringText(4, 1);
throw new ParseException("Unknown geometry type: " + type);

代码示例来源:origin: geotools/geotools

return readGeometryCollection();
throw new ParseException("Unknown WKB type " + geometryType);

代码示例来源:origin: geotools/geotools

throw new ParseException("Unknown WKB type " + geometryType);

代码示例来源:origin: locationtech/jts

/**
 * Creates a formatted ParseException reporting that the current token
 * was unexpected.
 *
 * @param msg a description of what was expected
 * @throws AssertionFailedException if an invalid token is encountered
 */
private static ParseException parseErrorWithLine(StreamTokenizer tokenizer, String msg)
{
 return new ParseException(msg + " (line " + tokenizer.lineno() + ")");
}

代码示例来源:origin: locationtech/geowave

public Geometry read(byte[] bytes) throws ParseException {
 try {
  ByteArrayInputStream in = new ByteArrayInputStream(bytes);
  DataInput input = new DataInputStream(in);
  return read(input);
 } catch (IOException e) {
  throw new ParseException("Error reading TWKB geometry.", e);
 }
}

代码示例来源:origin: locationtech/jts

private MultiLineString readMultiLineString() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 LineString[] geoms = new LineString[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof LineString))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
  geoms[i] = (LineString) g;
 }
 return factory.createMultiLineString(geoms);
}

代码示例来源:origin: locationtech/jts

private MultiPolygon readMultiPolygon() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Polygon[] geoms = new Polygon[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Polygon))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
  geoms[i] = (Polygon) g;
 }
 return factory.createMultiPolygon(geoms);
}

代码示例来源:origin: org.geoserver.geofence/geofence-model-internal

@Override
  public String marshal(Polygon the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Polygon obj is null.");
    }
  }
}

代码示例来源:origin: org.geoserver.geofence/geofence-model

@Override
  public String marshal(G the_geom) throws ParseException {
    if (the_geom != null) {
      WKTWriter wktWriter = new WKTWriter();
      if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

      return wktWriter.write(the_geom);
    } else {
      throw new ParseException("Geometry obj is null.");
    }
  }
}

相关文章