1 from django.contrib.gis.db import models
2 from madrona.features import register
3 from madrona.features.models import Feature
4 from django.utils.html import escape
5 from django.conf import settings
8 description = models.TextField(default="", null=True, blank=True)
9 latitude = models.FloatField()
10 longitude = models.FloatField()
11 altitude = models.FloatField()
12 heading = models.FloatField(default=0)
13 tilt = models.FloatField(default=0)
14 roll = models.FloatField(default=0)
15 altitudeMode = models.FloatField(default=1)
16 ip = models.IPAddressField(default="0.0.0.0", null=True, blank=True)
17 publicstate = models.TextField(default="{}")
18
19 @property
21 camera = "<Camera>\n"
22 camera_params = ["latitude", "longitude", "altitude", "heading", "tilt", "roll", "altitudeMode"]
23 for p in camera_params:
24 val = self.__dict__[p]
25 if val is not None:
26 camera += " <%s>%s</%s>\n" % (p, val, p)
27 camera += " </Camera>\n"
28
29 return """
30 <Placemark id="%s">
31 <visibility>1</visibility>
32 <name>%s</name>
33 <styleUrl>#%s-default</styleUrl>
34 <ExtendedData>
35 <Data name="descr"><value>%s</value></Data>
36 </ExtendedData>
37 %s
38 </Placemark>
39 """ % (self.uid, escape(self.name), self.model_uid(), escape(self.description), camera)
40
41 @property
43 return """
44 <Style id="%s-default">
45 <!-- invisible -->
46 <BalloonStyle>
47 <bgColor>ffeeeeee</bgColor>
48 <text> <![CDATA[
49 <h3>$[name]</h3>
50 <p>$[descr]</p>
51 ]]> </text>
52 </BalloonStyle>
53 <IconStyle>
54 <scale>0.0</scale>
55 </IconStyle>
56 <LabelStyle>
57 <scale>0.0</scale>
58 </LabelStyle>
59 </Style>
60 """ % (self.model_uid())
61
70
71 if settings.BOOKMARK_FEATURE:
72 Bookmark = register(Bookmark)
73