Examples of Kml


Examples of com.googlecode.libkml.Kml

    placemark.set_name("my placemark");
    placemark.set_id("pm123");
    placemark.set_geometry(point);

    // <kml>...
    Kml kml = factory.CreateKml();
    kml.set_feature(placemark);

    // NOTE: this _requires_ kmldom.
    System.out.print(kmldom.SerializePretty(kml));
  }
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

    return columnNameMap;
  }

  public File publishKML() throws FileNotFoundException {
    File outputFile = new File(ServletContextParameterMap.getParameterValue(ContextParameter.USER_DIRECTORY_PATH) + "KML/" + worksheet.getTitle() + ".kml");
    final Kml kml = KmlFactory.createKml();
    final Folder folder = kml.createAndSetFolder()
        .withName(worksheet.getTitle()).withOpen(true);

    Style style = folder.createAndAddStyle().withId("karma");
   
    if(randomCounter++%2 == 0)
      style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/blue-pushpin.png"));
    else
      style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/red-pushpin.png"));

    for (edu.isi.karma.geospatial.Point point : points) {
      folder.createAndAddPlacemark()
          .withDescription(point.getHTMLDescription())
          .withVisibility(true)
          .withStyleUrl("karma")
          .createAndSetPoint()
          .withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND)
          .addToCoordinates(
              point.getLongitude() + "," + point.getLatitude());

    }

    for (edu.isi.karma.geospatial.LineString line : lines) {
      folder.createAndAddPlacemark()
          .withDescription(line.getHTMLDescription())
          .withVisibility(true).createAndSetLineString()
          .withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND)
          .setCoordinates(line.getCoordinatesList());
    }
    int n=0;
    for (Polygon polygon: polygons) {
      FeatureTable featureTable = polygonTable.get(n);
     
      Placemark placemark = folder.createAndAddPlacemark()
      .withDescription(featureTable.getHTMLDescription())
      .withVisibility(true);
     
      final de.micromata.opengis.kml.v_2_2_0.Polygon kmlPolygon = new de.micromata.opengis.kml.v_2_2_0.Polygon();
      placemark.setGeometry(kmlPolygon);

      kmlPolygon.setExtrude(true);
      kmlPolygon.setAltitudeMode(AltitudeMode.CLAMP_TO_GROUND);

      final Boundary outerboundary = new Boundary();
      kmlPolygon.setOuterBoundaryIs(outerboundary);

      final LinearRing outerlinearring = new LinearRing();
      outerboundary.setLinearRing(outerlinearring);

      List<Coordinate> outercoord = new ArrayList<Coordinate>();
      outerlinearring.setCoordinates(outercoord);
      for (int i=0;i<polygon.getExteriorRing().getNumPoints();i++) {
        outercoord.add(new Coordinate(polygon.getExteriorRing().getPointN(i).getX(),polygon.getExteriorRing().getPointN(i).getY()));
      }
     
      int numOfInnerBoundaries = polygon.getNumInteriorRing();
      for(int i=0;i<numOfInnerBoundaries;i++)
      {
        final Boundary innerboundary = new Boundary();
        kmlPolygon.getInnerBoundaryIs().add(innerboundary);
 
        final LinearRing innerlinearring = new LinearRing();
        innerboundary.setLinearRing(innerlinearring);
 
        List<Coordinate> innercoord = new ArrayList<Coordinate>();
        innerlinearring.setCoordinates(innercoord);
        int numOfPoints = polygon.getInteriorRingN(i).getNumPoints();
        for(int j=0;j<numOfPoints;j++)
          innercoord.add(new Coordinate(polygon.getInteriorRingN(i).getPointN(j).getX(),polygon.getInteriorRingN(i).getPointN(j).getY()));
       
      }
     
     
    }
    kml.marshal(outputFile);
    logger.info("KML file published. Location:"
        + outputFile.getAbsolutePath());
    return outputFile;
  }
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

    // Setup a list of feeds
    @SuppressWarnings("unchecked")
    List<BasicDBObject> docs = (List<BasicDBObject>) rp.getData();
   
    // Setup the Kml object used to generate the kml document
    Kml kml = new Kml();
   
    // Create the document
    Document document = kml.createAndSetDocument()
      .withName("Infinit.e KML Interface"
      .withDescription("Infinit.e search KML representation");
   
    // Create the folder to contain the placemarks (allows us to have multiple folders
    Folder placemarksFolder = document.createAndAddFolder()
      .withName("Documents")
      .withDescription("Placemarks for the document locations in the query");
   
    // loop through the result set
    for ( BasicDBObject fdbo : docs)
    {
      // start out by checking to see if the title is not null
      if ( fdbo.getString("title") != null ) {
        // add logic to check for entities or event
        // Add in loop to create all the placemark points
       
        String description = "";
        if ( fdbo.getString("description") != null )
          description = fdbo.getString("description");
                 
        Point placemark = placemarksFolder.createAndAddPlacemark()
           .withName(fdbo.getString("title")).withOpen(Boolean.TRUE)
           .withDescription(description)
           .createAndSetPoint().addToCoordinates(-0.126236, 51.500152);
      }
    }
   
   
    // Create a string writer to contain the kml string
    StringWriter writer = new StringWriter();
    // marshal the string writer to get a string out to the kml object
    kml.marshal(writer);
   
    // return the kml to the client
    return writer.toString();

  }
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

  private Document document;

  private List<KmlModel> kmlModels;

  public KmlBuilder() {
    kml = new Kml();
    document = kml.createAndSetDocument().withName("");
  }
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

        response.setEntity(representation);
    }

    private KmlEncodingBundle buildKml(KmlEncodingContext encodingContext) {
        SimpleNetworkLinkBuilder nlBuilder = new SimpleNetworkLinkBuilder(encodingContext);
        Kml kml = nlBuilder.buildKMLDocument();

        Document doc = (Document) kml.getFeature();
        doc.createAndSetAtomAuthor();
        doc.setOpen(true);
        GeoServerInfo gsInfo = encodingContext.getWms().getGeoServer().getGlobal();
        String authorName = gsInfo.getSettings().getContact().getContactPerson();
        Author author = doc.createAndSetAtomAuthor();
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

        collections.add(fcObj);
        KmlEncodingContext context = new WFSKmlEncodingContext(gs.getService(WFSInfo.class),
                collections);

        // create the document
        Kml kml = new Kml();
        Document document = kml.createAndSetDocument();

        // get the callbacks for the document and let them loose
        List<KmlDecorator> docDecorators = context.getDecoratorsForClass(Document.class);
        for (KmlDecorator decorator : docDecorators) {
            document = (Document) decorator.decorate(document, context);
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

    public void write(Object value, OutputStream output, Operation operation) throws IOException,
            ServiceException {
        KMLMap kmlMap = (KMLMap) value;
        try {
            KmlEncodingContext context = kmlMap.getKmlEncodingContext();
            Kml kml = kmlMap.getKml();
            if (context != null && context.isKmz()) {
                encodeAsKmz(kml, context, operation, output);
            } else {
                encoder.encode(kml, output, context);
            }
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

    public KMLMap produceMap(WMSMapContent mapContent) throws ServiceException, IOException {
        // initialize the kml encoding context
        KmlEncodingContext context = new KmlEncodingContext(mapContent, wms, false);

        // build the kml document
        Kml kml = builder.buildKMLDocument(context);

        // return the map
        KMLMap map = new KMLMap(mapContent, context, kml, MIME_TYPE);
        map.setContentDispositionHeader(mapContent, ".kml");
        return map;
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

    public KMLMap produceMap(WMSMapContent mapContent) throws ServiceException, IOException {
        // initialize the kml encoding context
        KmlEncodingContext context = new KmlEncodingContext(mapContent, wms, true);

        // build the kml document
        Kml kml = builder.buildKMLDocument(context);

        // return the map
        KMLMap map = new KMLMap(mapContent, context, kml, MIME_TYPE);
        map.setContentDispositionHeader(mapContent, ".kmz");
        return map;
View Full Code Here

Examples of de.micromata.opengis.kml.v_2_2_0.Kml

        // prepare the encoding context
        List<SimpleFeatureCollection> collections = getFeatureCollections(featureCollection);
        KmlEncodingContext context = new WFSKmlEncodingContext(gs.getService(WFSInfo.class), collections);

        // create the document
        Kml kml = new Kml();
        Document document = kml.createAndSetDocument();

        // get the callbacks for the document and let them loose
        List<KmlDecorator> docDecorators = context.getDecoratorsForClass(Document.class);
        for (KmlDecorator decorator : docDecorators) {
            document = (Document) decorator.decorate(document, context);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.