Esempio n. 1
0
        public Object parseXMLObject(XMLObject xo) throws XMLParseException {

          double latitude = xo.getDoubleAttribute(LATITUDE);
          double longitude = xo.getDoubleAttribute(LONGITUDE);
          double radius = xo.getDoubleAttribute(RADIUS);
          int num = xo.getAttribute(NUMBER_OF_POINTS, 50); // default = 50

          LinkedList<Point2D> Point2Ds = getCirclePoints(latitude, longitude, num, radius);

          return new Polygon2D(Point2Ds, true);
        }
Esempio n. 2
0
        public Object parseXMLObject(XMLObject xo) throws XMLParseException {

          LinkedList<Point2D> Point2Ds = new LinkedList<Point2D>();
          boolean closed;
          Polygon2D polygon;

          if (xo.getChild(Polygon2D.class) != null) { // This is a regular polygon

            polygon = (Polygon2D) xo.getChild(Polygon2D.class);

          } else { // This is an arbitrary polygon

            KMLCoordinates coordinates = (KMLCoordinates) xo.getChild(KMLCoordinates.class);
            closed = xo.getAttribute(CLOSED, false);

            if ((!closed && coordinates.length < 3) || (closed && coordinates.length < 4))
              throw new XMLParseException(
                  "Insufficient point2Ds in polygon '"
                      + xo.getId()
                      + "' to define a polygon in 2D");

            for (int i = 0; i < coordinates.length; i++)
              Point2Ds.add(new Point2D.Double(coordinates.x[i], coordinates.y[i]));

            polygon = new Polygon2D(Point2Ds, closed);
          }

          polygon.setFillValue(xo.getAttribute(FILL_VALUE, 0.0));

          return polygon;
        }