source: subversion/applications/rendering/genericHeatmapRender/locationFinder.py @ 21375

Last change on this file since 21375 was 16116, checked in by stevefaeembra, 11 years ago

initial version.. very basic heatmapping code using Python/Matplotlib?

File size: 2.6 KB
Line 
1# -*- coding: UTF8 -*-
2'''
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License along
14    with this program; if not, write to the Free Software Foundation, Inc.,
15    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16'''
17
18from location import location
19import string
20
21class locationFinder(object):
22    '''
23    Responsible for generating a list of location objects
24    A series of location objects with (latitude/longitude/value)
25    This is a root class, specific locationFinder
26    implementations should subclass this class!
27    '''
28    locations=[]
29    bounds=None
30   
31    def __init__(self):
32        '''
33        Constructor
34        '''
35   
36    def addPoint(self, name, count, longitude,latitude):
37        if self.bounds == None:
38            self.locations.append(location(name,longitude,latitude,count))
39        else:
40            if (longitude>=self.bounds[0] and longitude<=self.bounds[2] and latitude>=self.bounds[1] and latitude<=self.bounds[3]):
41                self.locations.append(location(name,longitude,latitude,count))
42       
43    def query(self,query):
44        '''
45        Use this to populate self.locations with
46        a set of location objects
47        '''
48        pass
49   
50    def getX(self):
51        '''
52        returns list of longitudes
53        '''
54        return [l.long for l in self.locations] 
55   
56    def getY(self):
57        '''
58        returns list of latitudes
59        '''
60        return [l.lat for l in self.locations]
61   
62    def getZ(self):
63        '''
64        returns list of heights
65        '''
66        return [l.value for l in self.locations]
67   
68    def getNames(self):
69        '''
70        List of location titles
71        '''
72        return [l.name for l in self.locations]
73   
74    def getBounds(self):
75        '''
76        returns Bottom-left, top-right coords
77        (BL long, BL lat, TR long, TR lat)
78        '''
79        x=self.getX()
80        y=self.getY()
81        minX=min(x)
82        maxX=max(x)
83        minY=min(y)
84        maxY=max(y)
85        return (minX,minY,maxX,maxY)
86   
Note: See TracBrowser for help on using the repository browser.