-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathClone.cs
53 lines (46 loc) · 1.59 KB
/
Clone.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using SharpKml.Base;
using SharpKml.Dom;
using SharpKml.Engine; // Needed for the Clone extension method
namespace Examples
{
/// <summary>
/// Creates a single Region and adds it to two placemarks by using the
/// Clone extension method (normally there's an exception when you add
/// an Element to another instance when it already belongs to an Element)
/// </summary>
public static class Clone
{
public static void Run()
{
// Create a Container and some Features.
var placemark1 = new Placemark();
var placemark2 = new Placemark();
var folder = new Folder();
folder.AddFeature(placemark1);
folder.AddFeature(placemark2);
// Add a copy of the region to each Placemark
var region = CreateRegion();
placemark1.Region = region.Clone();
placemark2.Region = region.Clone();
// Display the result
var serializer = new Serializer();
serializer.Serialize(folder);
Console.WriteLine(serializer.Xml);
}
private static Region CreateRegion()
{
var box = new LatLonAltBox();
box.North = 1;
box.South = 2;
box.East = 3;
box.West = 4;
var lod = new Lod();
lod.MinimumPixels = 100;
var region = new Region();
region.LatLonAltBox = box;
region.LevelOfDetail = lod;
return region;
}
}
}