지대한
2 months ago
3 changed files with 244 additions and 15 deletions
@ -0,0 +1,136 @@
|
||||
package com.palnet.comn.utils; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute; |
||||
import javax.xml.bind.annotation.XmlRootElement; |
||||
import java.util.List; |
||||
|
||||
public class KmlUtils { |
||||
|
||||
// public static void main(String[] args) {
|
||||
// KmlPlacemark placemark = new KmlPlacemark();
|
||||
// placemark.setName("Test");
|
||||
// placemark.setDescription("This is a test placemark");
|
||||
// placemark.setLatitude(37.5665);
|
||||
// placemark.setLongitude(126.9780);
|
||||
// placemark.setElevation(0.0);
|
||||
//
|
||||
// String kml = convertToKml(placemark);
|
||||
// System.out.println(kml);
|
||||
// }
|
||||
// public static String convertToKml(KmlPlacemark placemark) {
|
||||
// try {
|
||||
// JAXBContext jaxbContext = JAXBContext.newInstance(KmlPlacemark.class);
|
||||
// Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
//
|
||||
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
//
|
||||
// StringWriter writer = new StringWriter();
|
||||
// marshaller.marshal(placemark, writer);
|
||||
//
|
||||
// return writer.toString();
|
||||
// } catch (JAXBException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "kml", namespace = "http://www.opengis.net/kml/2.2") |
||||
public static class KmlRoot<T> { |
||||
T kml; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "Document") |
||||
public static class KmlDocument { |
||||
private String name; |
||||
private String open; |
||||
private String description; |
||||
private List<KmlStyle> styles; |
||||
private List<KmlFolder> folders; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "Style") |
||||
public static class KmlStyle { |
||||
@XmlAttribute(name = "id") |
||||
private String id; |
||||
private KmlLineStyle LineStyle; |
||||
private KmlPolyStyle PolyStyle; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "LineStyle") |
||||
public static class KmlLineStyle { |
||||
private String color; |
||||
private String width; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "PolyStyle") |
||||
public static class KmlPolyStyle { |
||||
private String color; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "Folder") |
||||
public static class KmlFolder { |
||||
private String name; |
||||
private String description; |
||||
private KmlLookAt lookAt; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "LookAt") |
||||
public static class KmlLookAt { |
||||
double longitude; |
||||
double latitude; |
||||
@Builder.Default |
||||
double altitude = 0; |
||||
@Builder.Default |
||||
double heading = 0; |
||||
double tilt; |
||||
double range; |
||||
} |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
@Builder |
||||
@XmlRootElement(name = "Placemark") |
||||
public static class KmlPlacemark { |
||||
private String name; |
||||
private String description; |
||||
@Builder.Default |
||||
private int visibility = 1; |
||||
private String styleUrl; |
||||
private KmlLookAt lookAt; |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue