Beispiel #1
0
 def updatePoint(self, point: Point) -> Point:
     if len(point.id) != 24:
         return point
     col = self.getColl(point.mapId)
     result = col.update_one({'_id': ObjectId(point.id)},
                             {'$set': point.toDBMap()},
                             upsert=True)
     if result.upserted_id:
         point.id = str(result.upserted_id)
     path = edgeDao.findEdgeByPointAId(point.id, point.mapId)
     for item in path:
         item.pointA = {
             'id': point.id,
             'planCoordinate': point.planCoordinate,
             'actualCoordinate': point.actualCoordinate
         }
         edgeDao.updateEdge(item)
     path = edgeDao.findEdgeByPointBId(point.id, point.mapId)
     for item in path:
         item.pointB = {
             'id': point.id,
             'planCoordinate': point.planCoordinate,
             'actualCoordinate': point.actualCoordinate
         }
         edgeDao.updateEdge(item)
     return point
Beispiel #2
0
 def findById(self, id: str, mid: str) -> Point:
     col = self.getColl(mid)
     result = col.find_one({'_id': ObjectId(id)})
     if result is not None:
         point = Point(mid, result)
         point.id = id
         return point
     return None
Beispiel #3
0
 def findAll(self, mid: str) -> typing.List[Point]:
     col = self.getColl(mid)
     cursor = col.find()
     result = []
     for item in cursor:
         p = Point(item['mapId'], item)
         p.id = str(item['_id'])
         result.append(p)
     return result
Beispiel #4
0
 def _test_updatePoint(self):
     p = Point(
         '5e64cfce8aeb3647322e0880', {
             'planCoordinate': {
                 'x': 0,
                 'y': 70
             },
             'actualCoordinate': {
                 'x': 0,
                 'y': 70
             },
         })
     p.id = '5e64d614b40dda58e5e7b190'
     p = self.pointDao.updatePoint(p)
     print(p.toJsonMap())
Beispiel #5
0
 def savePoint(self, point: Point) -> Point:
     col = self.getColl(point.mapId)
     result = col.insert_one(point.toDBMap())
     point.id = str(result.inserted_id)
     return point
Beispiel #6
0
 def assemblePoint(self, item: dict) -> Point:
     p = Point(item['mapId'], item)
     p.id = str(item['_id'])
     return p