def Start(self, region): """ RegionHandler.Start() Split out the Features for this region. The overall sort is top-down given that the pre-recursion method is used to split out the input items. """ if not self._node_feature_set.has_key(region.Qid()): return [False, False] ifs = self._node_feature_set[region.Qid()] (fs, fs0, fs1, fs2, fs3) = ifs.Copy5Ways(region, self.__maxper) nitems = fs.Size() if nitems == 0: # nothing here, so nothing below either return [False, False] self._node_feature_set[region.Qid()] = fs if fs0: self._node_feature_set[region.Child('0').Qid()] = fs0 if fs1: self._node_feature_set[region.Child('1').Qid()] = fs1 if fs2: self._node_feature_set[region.Child('2').Qid()] = fs2 if fs3: self._node_feature_set[region.Child('3').Qid()] = fs3 if nitems == self.__maxper: # full load here, so maybe some below too return [True, True] # nitems < self.__maxper # didn't max out the region so no more for child regions return [True, False]
def Data(self, region): if not self.__node_feature_set.has_key(region.Qid()): return kml.genxml.Folder().xml( ) # XXX prune out no-data child kmls # A Folder to fill with one NetworkLink per Model kmz folder = kml.genxml.Folder() for (w, lon, lat, model) in self.__node_feature_set[region.Qid()]: # Create the NetworkLink to the kmz networklink = kml.genxml.NetworkLink() link = kml.genxml.Link() link.href = '../%s' % model.Kmz() networklink.Link = link.xml() # Add the NetworkLink to the Folder folder.Add_Feature(networklink.xml()) return folder.xml()
def Data(self, region): # We have our own Data because FeatureSetRegionHandler's Data # expects a feature in KML form. We operate in minidom node space. _kml = [] for (w, lon, lat, feature_dom_node) in self._node_feature_set[region.Qid()]: feature_kml = feature_dom_node.toxml() _kml.append(feature_kml) return "".join(_kml)
def Data(self, region): """ RegionHandler.Data() Create the KML objects for this Region. """ _kml = [] for (w, lon, lat, feature_kml) in self._node_feature_set[region.Qid()]: _kml.append( feature_kml) # feature_kml is "<Placemark>...</Placemark>" return "".join(_kml)
def Data(self, region): """ RegionHandler.Data() Create the KML objects for this Region. """ _kml = [] ritems = self.__qid_items[region.Qid()] for item in ritems: _kml.append(item[1]) return "".join(_kml)
def Start(self, region): """ If there are more than "nodemax" models in this region create links to children for them to consider. """ # XXX breaks if >__nodemax items at same pont fs = self.__feature_set.CopyByRegion(region) count = fs.Size() if count > self.__nodemax: # Too many for this node, push amongst children # XXX search each child to avoid building unecessary networklinks... return [True, True] # Maximum not exceeded, recurse no further self.__node_feature_set[region.Qid()] = fs return [True, False]
def CGIRegionate(region): # Find out what Region we are serving # and if we have child Regions (n, s, e, w) = region.NSEW() # Cannot bound maxLodPixels of the NetworkLink hierarchy # as the viewpoint can travel through the Region before # it triggers. # Cannot set minLodPixels too low or the client floods # the server with onRegion requests on any small viewpiont change. minpx = 128 maxpx = -1 document = kml.genxml.Document() document.name = region.Qid() style = kml.genxml.Style() styleid = 'mystyle' style.id = styleid a = 127 b = 127 g = 127 r = 127 style.LineStyle = kml.genkml.LineStyle(a, b, g, r) document.Region = kml.genkml.Region(n, s, e, w, minpx=minpx, maxpx=maxpx) children = kml.cgiregion.GetChildren(region) for q in children: document.Add_Feature( kml.cgiregion.LinkChild(baseurl, region, q, minpx, maxpx)) placemark = kml.genxml.Placemark() placemark.styleUrl = '#%s' % styleid placemark.Geometry = kml.genkml.LineStringBox(n, s, e, w) document.Add_Feature(placemark.xml()) k = kml.genxml.Kml() k.Feature = document.xml() return k.xml()
def Start(self, region): """ RegionHandler.Start() Split out the objects for this region. The overall sort is top-down given that the pre-recursion method is used to split out the input items. """ ritems = self.__featureq.Split(region, self.__maxper) nitems = len(ritems) if nitems == 0: # nothing here, so nothing below either return [False, False] self.__qid_items[region.Qid()] = ritems if nitems == self.__maxper: # full load here, so maybe some below too return [True, True] # nitems < self.__maxper # didn't max out the region so no more for child regions return [True, False]
def CreateQuery(region): (n, s, e, w) = region.NSEW() region = '%s=%s,%f,%f,%f,%f' % (regkey, region.Qid(), n, s, e, w) return region
def Kml(self, region, kmlfile, kml): print 'Kml ====', region.Id(), region.Qid(), region.NSEW()
def End(self, region): print 'End ====', region.Id(), region.Qid(), region.NSEW()
def Start(self, region): print 'Start ====', region.Id(), region.Qid(), region.NSEW() depth = region.Depth() if depth > 2: return [False, False] return [True, True]
def Data(self, region): (lon, lat) = region.MidPoint() return kml.genkml.PlacemarkPoint(lon, lat, region.Qid())