Пример #1
0
  protected void makeTessellatedLocations(
      Globe globe, int subdivisions, List<LatLon> locations, List<LatLon> tessellatedLocations) {
    ArrayList<Vec4> points = new ArrayList<Vec4>();
    for (LatLon ll : locations) {
      points.add(globe.computePointFromLocation(ll));
    }

    //noinspection StringEquality
    if (WWMath.computeWindingOrderOfLocations(locations) != AVKey.COUNTER_CLOCKWISE)
      Collections.reverse(locations);

    Vec4 centerPoint = Vec4.computeAveragePoint(points);
    Vec4 surfaceNormal = globe.computeSurfaceNormalAtPoint(centerPoint);

    int numPoints = points.size();
    float[] coords = new float[3 * numPoints];
    for (int i = 0; i < numPoints; i++) {
      points.get(i).toFloatArray(coords, 3 * i, 3);
    }

    GeometryBuilder gb = new GeometryBuilder();
    GeometryBuilder.IndexedTriangleArray tessellatedPoints =
        gb.tessellatePolygon(0, numPoints, coords, surfaceNormal);

    for (int i = 0; i < subdivisions; i++) {
      gb.subdivideIndexedTriangleArray(tessellatedPoints);
    }

    for (int i = 0; i < tessellatedPoints.getVertexCount(); i++) {
      Vec4 v = Vec4.fromFloatArray(tessellatedPoints.getVertices(), 3 * i, 3);
      tessellatedLocations.add(globe.computePositionFromPoint(v));
    }
  }
  /**
   * Build the resource map from the KML Model's <i>ResourceMap</i> element.
   *
   * @param model Model from which to create the resource map.
   * @return Map that relates relative paths in the COLLADA document to paths relative to the KML
   *     document.
   */
  protected Map<String, String> createResourceMap(KMLModel model) {
    Map<String, String> map = new HashMap<String, String>();

    KMLResourceMap resourceMap = model.getResourceMap();
    if (resourceMap == null) return Collections.emptyMap();

    for (KMLAlias alias : resourceMap.getAliases()) {
      if (alias != null
          && !WWUtil.isEmpty(alias.getSourceRef())
          && !WWUtil.isEmpty(alias.getTargetHref())) {
        map.put(alias.getSourceRef(), alias.getTargetHref());
      }
    }

    return map.size() > 0 ? map : Collections.<String, String>emptyMap();
  }
Пример #3
0
  protected void handleUnsuccessfulGeometryCreation() {
    // If creating the polygon geometry was unsuccessful, we modify the polygon to avoid any
    // additional creation
    // attempts, and free any resources that the polygon won't use. This is done to gracefully
    // handle
    // OutOfMemoryErrors throws while tessellating the polygon geometry.

    // Replace the polygon's locations with an empty list. This ensures that any rendering code
    // won't attempt to
    // re-create the polygon's geometry.
    this.locations = Collections.emptyList();
    // Reinitialize the polygon, since we've replaced its locations with an empty list.
    this.setExtentOutOfDate();
  }
  private void writeIFDs(List<TiffIFDEntry> ifds) throws IOException {
    long offset = this.theChannel.position();

    // This is supposed to start on a word boundary, via decree of the spec.
    long adjust = offset % 4L;
    offset += (adjust == 0) ? 0 : (4L - adjust);

    this.theChannel.position(offset);

    Collections.sort(ifds);

    ByteBuffer dataBuff = ByteBuffer.allocateDirect(ifds.size() * 12);

    // The IFD directory is preceeded by a SHORT count of the number of entries...
    putUnsignedShort(dataBuff, ifds.size());
    dataBuff.flip();
    this.theChannel.write(dataBuff);

    dataBuff.clear();
    for (TiffIFDEntry ifd : ifds) {
      putUnsignedShort(dataBuff, ifd.tag);
      putUnsignedShort(dataBuff, ifd.type);
      putUnsignedInt(dataBuff, ifd.count);
      if (ifd.type == Tiff.Type.SHORT && ifd.count == 1) {
        // these get packed in the first few bytes...
        putUnsignedShort(dataBuff, (int) ifd.valOffset);
        dataBuff.putShort((short) 0);
      } else putUnsignedInt(dataBuff, ifd.valOffset);
    }
    dataBuff.flip();
    this.theChannel.write(dataBuff);

    // The spec requires 4 bytes of zeros at the end...
    dataBuff.clear();
    dataBuff.putInt(0);
    dataBuff.flip();
    this.theChannel.write(dataBuff);

    // go back and patch up the ifd offset in header...
    this.theChannel.position(4);
    dataBuff.clear();
    putUnsignedInt(dataBuff, offset);
    dataBuff.flip();
    this.theChannel.write(dataBuff);
  }
Пример #5
0
 public java.util.List<AirspaceEntry> getEntries() {
   return Collections.unmodifiableList(this.entryList);
 }
Пример #6
0
 public List<LatLon> getLocations() {
   return Collections.unmodifiableList(this.locations);
 }
Пример #7
0
 /**
  * Returns the partial cylinders comprising the shape.
  *
  * @return the cylinders comprising the shape, or an empty list if the shape contains no layers.
  */
 public List<Layer> getLayers() {
   return Collections.unmodifiableList(this.layers);
 }