Esempio n. 1
0
def get_berkeley_sections():
    Sections = get_section_db()
    list_of_sections=[]
    for section in Sections.find():
        if section['section_start_point']!=None and section['section_end_point']!=None and \
            Inside_polygon(section['section_start_point'],berkeley_area()) and \
                Inside_polygon(section['section_end_point'],berkeley_area()):
            list_of_sections.append(section)
    return list_of_sections
Esempio n. 2
0
def get_berkeley_sections():
    Sections = get_section_db()
    list_of_sections = []
    for section in Sections.find():
        if section['section_start_point']!=None and section['section_end_point']!=None and \
            Inside_polygon(section['section_start_point'],berkeley_area()) and \
                Inside_polygon(section['section_end_point'],berkeley_area()):
            list_of_sections.append(section)
    return list_of_sections
    def testGeoWithOurStructureAndTestPolyFunction2(self):
        # pnt = {'type':'Point', 'coordinates': [40, +70]} # works1
        # pnt = {'type':'Point', 'coordinates': [40, +120]} # fails
        # pnt = {'type':'Point', 'coordinates': [35.5, +115]} # fails
        # pnt = {'type':'Point', 'coordinates': [35, +95]} # fails
        # pnt = {'type':'Point', 'coordinates': [35.5, +75]} # works2
        # pnt = {'type':'Point', 'coordinates': [35.5, +75.5]} # works2
        # pnt = {'type':'Point', 'coordinates': [35.5, +85.5]} # works3
        # pnt = {'type':'Point', 'coordinates': [35.5, +85.5]} # works4
        # pnt = {'type':'Point', 'coordinates': [35.5, +95.5]} # fails
        # pnt = {'type':'Point', 'coordinates': [35.5, +90.5]} # fails
        # pnt = {'type':'Point', 'coordinates': [35.5, +89.5]} # WORKS!
        # pnt = {'type':'Point', 'coordinates': [89.5, 35.5]} # works
        pnt = {"type": "Point", "coordinates": [90.5, 35.5]}  # works
        sec1 = {"track_location": pnt}
        self.Sections.insert(sec1)

        print common.Inside_polygon(pnt, common.berkeley_area())

        retVal = []
        for a in self.Sections.find({"track_location": {"$geoWithin": {"$polygon": self.getTestPolygon2()}}}):
            retVal.append(a)

        self.assertEquals(len(retVal), 1)
  def testGeoWithOurStructureAndTestPolyFunction2(self):
    # pnt = {'type':'Point', 'coordinates': [40, +70]} # works1
    # pnt = {'type':'Point', 'coordinates': [40, +120]} # fails
    # pnt = {'type':'Point', 'coordinates': [35.5, +115]} # fails
    # pnt = {'type':'Point', 'coordinates': [35, +95]} # fails
    # pnt = {'type':'Point', 'coordinates': [35.5, +75]} # works2
    # pnt = {'type':'Point', 'coordinates': [35.5, +75.5]} # works2
    # pnt = {'type':'Point', 'coordinates': [35.5, +85.5]} # works3
    # pnt = {'type':'Point', 'coordinates': [35.5, +85.5]} # works4
    # pnt = {'type':'Point', 'coordinates': [35.5, +95.5]} # fails
    # pnt = {'type':'Point', 'coordinates': [35.5, +90.5]} # fails
    # pnt = {'type':'Point', 'coordinates': [35.5, +89.5]} # WORKS!
    # pnt = {'type':'Point', 'coordinates': [89.5, 35.5]} # works
    pnt = {'type':'Point', 'coordinates': [90.5, 35.5]} # works
    sec1 = {'track_location': pnt}
    self.Sections.insert(sec1)

    print common.Inside_polygon(pnt, common.berkeley_area())

    retVal = []
    for a in self.Sections.find({ "track_location" : { "$geoWithin" : { "$polygon" : self.getTestPolygon2() } } }):
        retVal.append(a)

    self.assertEquals(len(retVal), 1)