本文整理了Java中de.micromata.opengis.kml.v_2_2_0.Kml
类的一些代码示例,展示了Kml
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kml
类的具体详情如下:
包路径:de.micromata.opengis.kml.v_2_2_0.Kml
类名称:Kml
[英]...
A basic element contains 0 or 1 Feature and 0 or 1 NetworkLinkControl:
The element may also include the namespace for any external XML schemas that are referenced within the file.
The root element of a KML file. This element is required. It follows the xml declaration at the beginning of the file. The hint attribute is used as a signal to Google Earth to display the file as celestial data.
Syntax:
<kml xmlns="http://www.opengis.net/kml/2.2" hint="target=sky"> ... </kml>
[中]...
基本元素包含0或1个功能和0或1个NetworkLinkControl:
元素还可以包括文件中引用的任何外部XML模式的名称空间。
KML文件的根元素。此元素是必需的。它遵循文件开头的xml声明。提示属性被用作谷歌地球的信号,以将文件显示为天体数据。
语法:
<kml xmlns="http://www.opengis.net/kml/2.2" hint="target=sky"> ... </kml>
代码示例来源:origin: stackoverflow.com
final Kml kml = new Kml();
Document document = kml.createAndSetDocument();
listForms = formDAO.getAll();
for (Form list : listForms){
document.createAndAddPlacemark()
.withName(String.valueOf(list.getId()))
.withDescription(list.toStringKML())
.createAndSetPoint().addToCoordinates(-20.3978398, -43.5146653);
}
kml.setFeature(document);
kml.marshal(new File("test.kml"));
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
/**
* Internal method
*
*/
private void addKmzFile(Kml kmzFile, ZipOutputStream out, boolean mainfile)
throws IOException
{
String fileName = null;
if (((kmzFile.getFeature() == null)||(kmzFile.getFeature().getName() == null))||(kmzFile.getFeature().getName().length() == 0)) {
fileName = (("noFeatureNameSet"+ missingNameCounter ++)+".kml");
} else {
fileName = kmzFile.getFeature().getName();
if (!fileName.endsWith(".kml")) {
fileName += ".kml";
}
}
if (mainfile) {
fileName = "doc.kml";
}
out.putNextEntry(new ZipEntry(URLEncoder.encode(fileName, "UTF-8")));
kmzFile.marshal(out);
out.closeEntry();
}
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
public boolean marshalAsKmz(
@NotNull
String name, Kml... additionalFiles)
throws IOException
{
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(name));
out.setComment("KMZ-file created with Java API for KML. Visit us: http://code.google.com/p/javaapiforkml/");
this.addKmzFile(this, out, true);
for (Kml kml: additionalFiles) {
this.addKmzFile(kml, out, false);
}
out.close();
missingNameCounter = 1;
return false;
}
代码示例来源:origin: stackoverflow.com
Marshaller m = JAXBContext.newInstance(new Class[] { Kml.class }).createMarshaller();
m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true );
m.setProperty( Marshaller.JAXB_FRAGMENT, false );
m.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8");
final Kml kml = new Kml();
kml.createAndSetPlacemark()
.withName("London, UK").withOpen(Boolean.TRUE)
.createAndSetPoint().addToCoordinates(-0.126236, 51.500152);
StringWriter sw = new StringWriter();
m.marshal(kml,sw);
String s1 = sw.toString();
System.out.println(s1);
代码示例来源:origin: org.geoserver/kml
public Kml buildKMLDocument() {
// prepare kml, document and folder
Kml kml = new Kml();
Document document = kml.createAndSetDocument();
Map formatOptions = context.getRequest().getFormatOptions();
String kmltitle = (String) formatOptions.get("kmltitle");
if(kmltitle == null) {
kmltitle = context.getMapContent().getTitle();
}
document.setName(kmltitle);
// get the callbacks for the document and let them loose
List<KmlDecorator> decorators = context.getDecoratorsForClass(Document.class);
for (KmlDecorator decorator : decorators) {
document = (Document) decorator.decorate(document, context);
if (document == null) {
throw new ServiceException("Coding error in decorator " + decorator
+ ", document objects cannot be set to null");
}
}
encodeDocumentContents(document);
return kml;
}
代码示例来源:origin: micromata/javaapiforkml
/**
* Create an instance of {@link Kml}
*
*/
public static Kml createKml() {
return new Kml();
}
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
/**
* fluent setter
* @see #setFeature(Feature)
*
* @param feature
* required parameter
*/
public Kml withFeature(final Feature feature) {
this.setFeature(feature);
return this;
}
代码示例来源:origin: stackoverflow.com
final Kml kml = new Kml();
final Folder folder = new Folder();
kml.setFeature(folder);
folder.setName("Folder.kml");
folder.setOpen(true);
final Placemark placemark1 = new Placemark().withId("1")
.withName("Folder object 1 (Placemark)");
folder.getFeature().add(placemark1);
final Placemark placemark2 = new Placemark().withId("2")
.withName("Folder object 2 (Placemark)");
folder.getFeature().add(placemark2);
List<Feature> features = folder.getFeature();
System.out.println(features); // dumps two features
for(int i=features.size()-1; i >= 0; i--)
{
Feature f = features.get(i);
if("1".equals(f.getId()))
{
// this removes feature with id = "1"
features.remove(i);
break;
}
}
System.out.println(features); // folder now only has one item
代码示例来源:origin: usc-isi-i2/Web-Karma
final Folder folder = kml.createAndSetFolder()
.withName(worksheet.getTitle()).withOpen(true);
LookAt lookat = new LookAt();
kml.marshal(out);
String test = out.toString();
Writer outUTF8;
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
/**
* Java to KML
* The object graph is marshalled to a File object.
* The object is not saved as a zipped .kmz file.
* @see marshalKmz(String, Kml...)
*
*/
public boolean marshal(final File filename)
throws FileNotFoundException
{
OutputStream out = new FileOutputStream(filename);
return this.marshal(out);
}
代码示例来源:origin: stackoverflow.com
Assert.assertNotNull(is);
Kml kml = Kml.unmarshal(is);
Feature feature = kml.getFeature();
parseFeature(feature);
代码示例来源:origin: org.geoserver/kml
/**
* Builds a lazily evaluated KML document given a encoding context
*
* @param context
* @return
*/
public Kml buildKMLDocument(KmlEncodingContext context) {
// prepare kml, document and folder
Kml kml = new Kml();
Document document = kml.createAndSetDocument();
String kmltitle = (String) context.getRequest().getFormatOptions().get("kmltitle");
document.setName(kmltitle);
// get the callbacks for the document and let them loose
List<KmlDecorator> decorators = context.getDecoratorsForClass(Document.class);
for (KmlDecorator decorator : decorators) {
document = (Document) decorator.decorate(document, context);
if (document == null) {
throw new ServiceException("Coding error in decorator " + decorator
+ ", document objects cannot be set to null");
}
}
// create a generator that will generate a folder and feature dumps/ground overlays for each
// layer
SequenceFactory<Feature> generatorFactory = new PlainFolderSequenceFactory(context);
SequenceList<Feature> folders = new SequenceList<Feature>(generatorFactory);
context.addFeatures(document, folders);
return kml;
}
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
/**
* Create an instance of {@link Kml}
*
*/
public static Kml createKml() {
return new Kml();
}
代码示例来源:origin: micromata/javaapiforkml
/**
* fluent setter
* @see #setFeature(Feature)
*
* @param feature
* required parameter
*/
public Kml withFeature(final Feature feature) {
this.setFeature(feature);
return this;
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public File publishKML() throws FileNotFoundException {
File outputFile = new File(ContextParametersRegistry.getInstance().getDefault().getParameterValue(ContextParameter.KML_PUBLISH_DIR) + worksheet.getTitle() + ".kml");
final Kml kml = KmlFactory.createKml();
final Folder folder = kml.createAndSetFolder()
.withName(worksheet.getTitle()).withOpen(true);
kml.marshal(outputFile);
logger.info("KML file published. Location:"
+ outputFile.getAbsolutePath());
代码示例来源:origin: micromata/javaapiforkml
/**
* Java to KML
* The object graph is marshalled to a File object.
* The object is not saved as a zipped .kmz file.
* @see marshalKmz(String, Kml...)
*
*/
public boolean marshal(final File filename)
throws FileNotFoundException
{
OutputStream out = new FileOutputStream(filename);
return this.marshal(out);
}
代码示例来源:origin: org.geoserver.community/gs-wps-download
throws IOException {
Kml kml = new Kml();
Document document = kml.createAndSetDocument();
Folder folder = document.createAndAddFolder();
GroundOverlay go = folder.createAndAddGroundOverlay();
代码示例来源:origin: stackoverflow.com
final Kml __balloonKML = new Kml();
代码示例来源:origin: de.micromata.jak/JavaAPIforKml
/**
* Creates a new instance of {@link ScreenOverlay} and set it to feature.
*
* This method is a short version for:
* <code>
* ScreenOverlay screenOverlay = new ScreenOverlay();
* this.setFeature(screenOverlay); </code>
*
*
*/
public ScreenOverlay createAndSetScreenOverlay() {
ScreenOverlay newValue = new ScreenOverlay();
this.setFeature(newValue);
return newValue;
}
代码示例来源:origin: micromata/javaapiforkml
/**
* Internal method
*
*/
private void addKmzFile(Kml kmzFile, ZipOutputStream out, boolean mainfile)
throws IOException
{
String fileName = null;
if (((kmzFile.getFeature() == null)||(kmzFile.getFeature().getName() == null))||(kmzFile.getFeature().getName().length() == 0)) {
fileName = (("noFeatureNameSet"+ missingNameCounter ++)+".kml");
} else {
fileName = kmzFile.getFeature().getName();
if (!fileName.endsWith(".kml")) {
fileName += ".kml";
}
}
if (mainfile) {
fileName = "doc.kml";
}
out.putNextEntry(new ZipEntry(URLEncoder.encode(fileName, "UTF-8")));
kmzFile.marshal(out);
out.closeEntry();
}
内容来源于网络,如有侵权,请联系作者删除!