def testGetBounds(self):
     dt1 = datetime(2015, 1, 1, 1, 1, 1)
     dt2 = datetime(2015, 1, 1, 2, 1, 1)
     dt3 = datetime(2015, 1, 2, 3, 1, 1)
     sectionJsonList = []
     sectionJsonList.append({"_id": "foo_1",
         "user_id": "test_user",
         "type":"move",
         "section_id": 3,
         "section_start_datetime": dt1,
         "section_end_datetime": dt2,
         "section_start_point": {"coordinates": [1,2], "type": "Point"},
         "section_end_point": {"coordinates": [3,4], "type": "Point"}})
     sectionJsonList.append({"_id": "foo_2",
         "user_id": "test_user",
         "type":"place",
         "section_start_datetime": dt2,
         "section_end_datetime": dt3,
         "section_start_point": {"coordinates": [5,6], "type": "Point"},
         "section_end_point": {"coordinates": [7,8], "type": "Point"}})
     sectionJsonList.append({"_id": "foo_3",
         "user_id": "test_user",
         "type": "move",
         "section_id": 0,
         "section_start_datetime": dt3,
         "section_start_point": {"coordinates": [9,10], "type": "Point"},
         "section_end_point": {"coordinates": [11,12], "type": "Point"}})
     bounds = tauq.get_bounds(sectionJsonList)
     self.assertEqual(bounds[0].lat, 2)
     self.assertEqual(bounds[0].lon, 1)
     self.assertEqual(bounds[1].lat, 12)
     self.assertEqual(bounds[1].lon, 11)
 def testGetBounds(self):
     dt1 = datetime(2015, 1, 1, 1, 1, 1)
     dt2 = datetime(2015, 1, 1, 2, 1, 1)
     dt3 = datetime(2015, 1, 2, 3, 1, 1)
     sectionJsonList = []
     sectionJsonList.append({"_id": "foo_1",
         "user_id": "test_user",
         "type":"move",
         "section_id": 3,
         "section_start_datetime": dt1,
         "section_end_datetime": dt2,
         "section_start_point": {"coordinates": [1,2], "type": "Point"},
         "section_end_point": {"coordinates": [3,4], "type": "Point"}})
     sectionJsonList.append({"_id": "foo_2",
         "user_id": "test_user",
         "type":"place",
         "section_start_datetime": dt2,
         "section_end_datetime": dt3,
         "section_start_point": {"coordinates": [5,6], "type": "Point"},
         "section_end_point": {"coordinates": [7,8], "type": "Point"}})
     sectionJsonList.append({"_id": "foo_3",
         "user_id": "test_user",
         "type": "move",
         "section_id": 0,
         "section_start_datetime": dt3,
         "section_start_point": {"coordinates": [9,10], "type": "Point"},
         "section_end_point": {"coordinates": [11,12], "type": "Point"}})
     bounds = tauq.get_bounds(sectionJsonList)
     self.assertEqual(bounds[0].lat, 2)
     self.assertEqual(bounds[0].lon, 1)
     self.assertEqual(bounds[1].lat, 12)
     self.assertEqual(bounds[1].lon, 11)
def drawSectionsFromList(sectionIdList, outPath):
    sectionJsonList = [get_section_db().find_one({"_id": sid}) for sid in sectionIdList]

    bounds = tauq.get_bounds(sectionJsonList)
    gmap = pygmaps.maps(old_div((bounds[0].lat + bounds[1].lat),2), old_div((bounds[0].lon + bounds[1].lon),2), 10)

    drawSections(sectionJsonList, ALL, gmap, "random")
    gmap.draw(outPath)
示例#4
0
def drawSectionsFromList(sectionIdList, outPath):
    sectionJsonList = [
        get_section_db().find_one({"_id": sid}) for sid in sectionIdList
    ]

    bounds = tauq.get_bounds(sectionJsonList)
    gmap = pygmaps.maps(old_div((bounds[0].lat + bounds[1].lat), 2),
                        old_div((bounds[0].lon + bounds[1].lon), 2), 10)

    drawSections(sectionJsonList, ALL, gmap, "random")
    gmap.draw(outPath)