find.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Mar 19 11:09:30 2013
  4. @author: pietro
  5. """
  6. import grass.lib.vector as libvect
  7. from grass.pygrass.errors import must_be_open
  8. from grass.pygrass.vector.basic import Ilist, BoxList
  9. from grass.pygrass.vector.geometry import read_line, Isle, Area, Point, Node
  10. # For test purposes
  11. test_vector_name = "find_doctest_map"
  12. class AbstractFinder(object):
  13. def __init__(self, c_mapinfo, table=None, writeable=False):
  14. """AbstractFinder
  15. -----------------
  16. Find geometry feature around a point.
  17. """
  18. self.c_mapinfo = c_mapinfo
  19. self.table = table
  20. self.writeable = writeable
  21. self.vtype = {'point': libvect.GV_POINT, # 1
  22. 'line': libvect.GV_LINE, # 2
  23. 'boundary': libvect.GV_BOUNDARY, # 3
  24. 'centroid': libvect.GV_CENTROID, # 4
  25. 'all': -1}
  26. def is_open(self):
  27. """Check if the vector map is open or not"""
  28. from . import abstract
  29. return abstract.is_open(self.c_mapinfo)
  30. class PointFinder(AbstractFinder):
  31. """Point finder
  32. This class provides an interface to search geometry features
  33. of a vector map that are close to a point. The PointFinder class
  34. is part of a topological vector map object.
  35. """
  36. def __init__(self, c_mapinfo, table=None, writeable=False):
  37. """Find geometry feature(s) around a point.
  38. :param c_mapinfo: Pointer to the vector layer mapinfo structure
  39. :type c_mapinfo: ctypes pointer to mapinfo structure
  40. :param table: Attribute table of the vector layer
  41. :type table: Class Table from grass.pygrass.table
  42. :param writable: True or False
  43. :type writeable: boolean
  44. """
  45. super(PointFinder, self).__init__(c_mapinfo, table, writeable)
  46. @must_be_open
  47. def node(self, point, maxdist):
  48. """Find the nearest node around a specific point.
  49. :param point: The point to search
  50. :type point: grass.pygrass.vector.geometry.Point
  51. :param maxdist: The maximum search distance around the point
  52. :type maxdist: float
  53. :return: A grass.pygrass.vector.geometry.Node if found or None
  54. This methods uses libvect.Vect_find_node()()
  55. Examples:
  56. >>> from grass.pygrass.vector import VectorTopo
  57. >>> from grass.pygrass.vector.geometry import Point
  58. >>> test_vect = VectorTopo(test_vector_name)
  59. >>> test_vect.open('r')
  60. # Find nearest node
  61. >>> points = (Point(10,0), Point(10,4), Point(14,0))
  62. >>> result = []
  63. >>> for point in points:
  64. ... f = test_vect.find_by_point.node(point=point, maxdist=1)
  65. ... if f:
  66. ... result.append(f)
  67. >>> result
  68. [Node(2), Node(1), Node(6)]
  69. >>> test_vect.find_by_point.node(point=Point(20,20), maxdist=0)
  70. >>> test_vect.close()
  71. """
  72. node_id = libvect.Vect_find_node(self.c_mapinfo, point.x,
  73. point.y,
  74. point.z if point.z else 0,
  75. float(maxdist),
  76. int(not point.is2D))
  77. if node_id:
  78. return Node(v_id=node_id, c_mapinfo=self.c_mapinfo,
  79. table=self.table, writeable=self.writeable)
  80. @must_be_open
  81. def geo(self, point, maxdist, type='all', exclude=0):
  82. """Find the nearest vector feature around a specific point.
  83. :param point: The point to search
  84. :type point: grass.pygrass.vector.geometry.Point
  85. :param maxdist: The maximum search distance around the point
  86. :type maxdist: float
  87. :param type: The type of feature to search for
  88. Valid type are all the keys in find.vtype dictionary
  89. :type type: string
  90. :param exclude: if > 0 number of lines which should be
  91. excluded from selection
  92. :return: A grass.pygrass.vector.geometry.Node if found or None
  93. This methods uses libvect.Vect_find_line()()
  94. Examples:
  95. >>> from grass.pygrass.vector import VectorTopo
  96. >>> from grass.pygrass.vector.geometry import Point
  97. >>> test_vect = VectorTopo(test_vector_name)
  98. >>> test_vect.open('r')
  99. # Find single features
  100. >>> points = (Point(10,0), Point(10,6), Point(14,2))
  101. >>> result = []
  102. >>> for point in points:
  103. ... f = test_vect.find_by_point.geo(point=point, maxdist=1)
  104. ... if f:
  105. ... result.append(f)
  106. >>> for f in result:
  107. ... print(f.to_wkt()) #doctest: +NORMALIZE_WHITESPACE
  108. LINESTRING(10.000000 4.000000,
  109. 10.000000 2.000000,
  110. 10.000000 0.000000)
  111. POINT(10.000000 6.000000)
  112. LINESTRING(14.000000 4.000000,
  113. 14.000000 2.000000,
  114. 14.000000 0.000000)
  115. >>> test_vect.find_by_point.geo(point=Point(20,20), maxdist=0)
  116. >>> test_vect.close()
  117. """
  118. feature_id = libvect.Vect_find_line(self.c_mapinfo,
  119. point.x, point.y,
  120. point.z if point.z else 0,
  121. self.vtype[type], float(maxdist),
  122. int(not point.is2D), exclude)
  123. if feature_id:
  124. return read_line(feature_id, self.c_mapinfo,
  125. self.table, self.writeable)
  126. @must_be_open
  127. def geos(self, point, maxdist, type='all', exclude=None):
  128. """Find the nearest vector features around a specific point.
  129. :param point: The point to search
  130. :type point: grass.pygrass.vector.geometry.Point
  131. :param maxdist: The maximum search distance around the point
  132. :type maxdist: float
  133. :param type: The type of feature to search for
  134. Valid type are all the keys in find.vtype dictionary
  135. :type type: string
  136. :param exclude: if > 0 number of lines which should be
  137. excluded from selection
  138. :return: A list of grass.pygrass.vector.geometry
  139. (Line, Point, Boundary, Centroid) if found or None
  140. This methods uses libvect.Vect_find_line_list()()
  141. Examples:
  142. >>> from grass.pygrass.vector import VectorTopo
  143. >>> from grass.pygrass.vector.geometry import Point
  144. >>> test_vect = VectorTopo(test_vector_name)
  145. >>> test_vect.open('r')
  146. # Find multiple features
  147. >>> points = (Point(10,0), Point(10,5), Point(14,2))
  148. >>> result = []
  149. >>> for point in points:
  150. ... f = test_vect.find_by_point.geos(point=point,
  151. ... maxdist=1.5)
  152. ... if f:
  153. ... result.append(f)
  154. >>> for f in result:
  155. ... print(f) #doctest: +NORMALIZE_WHITESPACE
  156. [Line([Point(10.000000, 4.000000),
  157. Point(10.000000, 2.000000),
  158. Point(10.000000, 0.000000)])]
  159. [Line([Point(10.000000, 4.000000),
  160. Point(10.000000, 2.000000),
  161. Point(10.000000, 0.000000)]),
  162. Point(10.000000, 6.000000)]
  163. [Line([Point(14.000000, 4.000000),
  164. Point(14.000000, 2.000000),
  165. Point(14.000000, 0.000000)])]
  166. # Find multiple boundaries
  167. >>> point = Point(3,3)
  168. >>> result = test_vect.find_by_point.geos(point=Point(3,3),
  169. ... type="boundary",
  170. ... maxdist=1.5)
  171. >>> result #doctest: +NORMALIZE_WHITESPACE
  172. [Boundary([Point(0.000000, 4.000000), Point(4.000000, 4.000000)]),
  173. Boundary([Point(4.000000, 4.000000), Point(4.000000, 0.000000)]),
  174. Boundary([Point(1.000000, 1.000000), Point(1.000000, 3.000000),
  175. Point(3.000000, 3.000000), Point(3.000000, 1.000000),
  176. Point(1.000000, 1.000000)]),
  177. Boundary([Point(4.000000, 4.000000), Point(6.000000, 4.000000)])]
  178. # Find multiple centroids
  179. >>> point = Point(3,3)
  180. >>> result = test_vect.find_by_point.geos(point=Point(3,3),
  181. ... type="centroid",
  182. ... maxdist=1.5)
  183. >>> result #doctest: +NORMALIZE_WHITESPACE
  184. [Centoid(2.500000, 2.500000),
  185. Centoid(3.500000, 3.500000)]
  186. >>> test_vect.find_by_point.geos(point=Point(20,20), maxdist=0)
  187. >>> test_vect.close()
  188. """
  189. excl = Ilist(exclude) if exclude else Ilist([])
  190. found = Ilist()
  191. if libvect.Vect_find_line_list(self.c_mapinfo,
  192. point.x, point.y,
  193. point.z if point.z else 0,
  194. self.vtype[type], float(maxdist),
  195. int(not point.is2D),
  196. excl.c_ilist, found.c_ilist):
  197. return [read_line(f_id, self.c_mapinfo, self.table, self.writeable)
  198. for f_id in found]
  199. @must_be_open
  200. def area(self, point):
  201. """Find the nearest area around a specific point.
  202. :param point: The point to search
  203. :type point: grass.pygrass.vector.geometry.Point
  204. :return: A grass.pygrass.vector.geometry.Area if found or None
  205. This methods uses libvect.Vect_find_area()
  206. Examples:
  207. >>> from grass.pygrass.vector import VectorTopo
  208. >>> from grass.pygrass.vector.geometry import Point
  209. >>> test_vect = VectorTopo(test_vector_name)
  210. >>> test_vect.open('r')
  211. # Find AREAS
  212. >>> points = (Point(0.5,0.5), Point(5,1), Point(7,1))
  213. >>> result = []
  214. >>> for point in points:
  215. ... area = test_vect.find_by_point.area(point)
  216. ... result.append(area)
  217. >>> result
  218. [Area(1), Area(2), Area(4)]
  219. >>> for area in result:
  220. ... print(area.to_wkt()) #doctest: +NORMALIZE_WHITESPACE
  221. Polygon((0.000000 0.000000, 0.000000 4.000000, 4.000000 4.000000,
  222. 4.000000 0.000000, 0.000000 0.000000))
  223. Polygon((4.000000 0.000000, 4.000000 4.000000, 6.000000 4.000000,
  224. 6.000000 0.000000, 4.000000 0.000000))
  225. Polygon((6.000000 0.000000, 6.000000 4.000000, 8.000000 4.000000,
  226. 8.000000 0.000000, 6.000000 0.000000))
  227. >>> test_vect.find_by_point.area(Point(20,20))
  228. >>> test_vect.close()
  229. """
  230. area_id = libvect.Vect_find_area(self.c_mapinfo, point.x, point.y)
  231. if area_id:
  232. return Area(v_id=area_id, c_mapinfo=self.c_mapinfo,
  233. table=self.table, writeable=self.writeable)
  234. @must_be_open
  235. def island(self, point):
  236. """Find the nearest island around a specific point.
  237. :param point: The point to search
  238. :type point: grass.pygrass.vector.geometry.Point
  239. :return: A grass.pygrass.vector.geometry.Isle if found or None
  240. This methods uses Vect_find_island.Vect_find_area()
  241. Examples:
  242. >>> from grass.pygrass.vector import VectorTopo
  243. >>> from grass.pygrass.vector.geometry import Point
  244. >>> test_vect = VectorTopo(test_vector_name)
  245. >>> test_vect.open('r')
  246. # Find ISLANDS
  247. >>> points = (Point(2,2), Point(5,1))
  248. >>> result = []
  249. >>> for point in points:
  250. ... area = test_vect.find_by_point.island(point)
  251. ... result.append(area)
  252. >>> result
  253. [Isle(2), Isle(1)]
  254. >>> for isle in result:
  255. ... print(isle.to_wkt()) #doctest: +NORMALIZE_WHITESPACE
  256. Polygon((1.000000 1.000000, 3.000000 1.000000,
  257. 3.000000 3.000000, 1.000000 3.000000, 1.000000 1.000000))
  258. Polygon((0.000000 4.000000, 0.000000 0.000000, 4.000000 0.000000,
  259. 6.000000 0.000000, 8.000000 0.000000, 8.000000 4.000000,
  260. 6.000000 4.000000, 4.000000 4.000000, 0.000000 4.000000))
  261. >>> test_vect.find_by_point.island(Point(20,20))
  262. >>> test_vect.close()
  263. """
  264. isle_id = libvect.Vect_find_island(self.c_mapinfo, point.x, point.y)
  265. if isle_id:
  266. return Isle(v_id=isle_id, c_mapinfo=self.c_mapinfo,
  267. table=self.table, writeable=self.writeable)
  268. class BboxFinder(AbstractFinder):
  269. """Bounding Box finder
  270. This class provides an interface to search geometry features
  271. of a vector map that are inside or intersect a boundingbox.
  272. The BboxFinder class
  273. is part of a topological vector map object.
  274. """
  275. def __init__(self, c_mapinfo, table=None, writeable=False):
  276. """Find geometry feature(s)that are insider or intersect
  277. with a boundingbox.
  278. :param c_mapinfo: Pointer to the vector layer mapinfo structure
  279. :type c_mapinfo: ctypes pointer to mapinfo structure
  280. :param table: Attribute table of the vector layer
  281. :type table: Class Table from grass.pygrass.table
  282. :param writable: True or False
  283. :type writeable: boolean
  284. """
  285. super(BboxFinder, self).__init__(c_mapinfo, table, writeable)
  286. @must_be_open
  287. def geos(self, bbox, type='all', bboxlist_only=False):
  288. """Find the nearest vector features around a specific point.
  289. :param bbox: The boundingbox to search in
  290. :type bbox: grass.pygrass.vector.basic.Bbox
  291. :param type: The type of feature to search for
  292. Valid type are all the keys in find.vtype dictionary
  293. :type type: string
  294. :param bboxlist_only: If true the BoxList will be returned,
  295. no features are generated
  296. :type bboxlist_only: boolean
  297. :return: A list of grass.pygrass.vector.geometry
  298. (Line, Point, Boundary, Centroid) if found,
  299. or None if nothing was found.
  300. If bboxlist_only is True a BoxList
  301. object will be returned, or None if nothing was found.
  302. This methods uses libvect.Vect_select_lines_by_box()
  303. Examples:
  304. >>> from grass.pygrass.vector import VectorTopo
  305. >>> from grass.pygrass.vector.basic import Bbox
  306. >>> test_vect = VectorTopo(test_vector_name)
  307. >>> test_vect.open('r')
  308. >>> bbox = Bbox(north=5, south=-1, east=3, west=-1)
  309. >>> result = test_vect.find_by_bbox.geos(bbox=bbox)
  310. >>> result #doctest: +NORMALIZE_WHITESPACE
  311. [Boundary([Point(4.000000, 0.000000), Point(0.000000, 0.000000)]),
  312. Boundary([Point(0.000000, 0.000000), Point(0.000000, 4.000000)]),
  313. Boundary([Point(0.000000, 4.000000), Point(4.000000, 4.000000)]),
  314. Boundary([Point(1.000000, 1.000000), Point(1.000000, 3.000000),
  315. Point(3.000000, 3.000000), Point(3.000000, 1.000000),
  316. Point(1.000000, 1.000000)]),
  317. Centoid(2.500000, 2.500000)]
  318. >>> bbox = Bbox(north=5, south=-1, east=3, west=-1)
  319. >>> result = test_vect.find_by_bbox.geos(bbox=bbox,
  320. ... bboxlist_only=True)
  321. >>> result #doctest: +NORMALIZE_WHITESPACE
  322. Boxlist([Bbox(0.0, 0.0, 4.0, 0.0),
  323. Bbox(4.0, 0.0, 0.0, 0.0),
  324. Bbox(4.0, 4.0, 4.0, 0.0),
  325. Bbox(3.0, 1.0, 3.0, 1.0),
  326. Bbox(2.5, 2.5, 2.5, 2.5)])
  327. >>> bbox = Bbox(north=7, south=-1, east=15, west=9)
  328. >>> result = test_vect.find_by_bbox.geos(bbox=bbox)
  329. >>> result #doctest: +NORMALIZE_WHITESPACE
  330. [Line([Point(10.000000, 4.000000), Point(10.000000, 2.000000),
  331. Point(10.000000, 0.000000)]),
  332. Point(10.000000, 6.000000),
  333. Line([Point(12.000000, 4.000000), Point(12.000000, 2.000000),
  334. Point(12.000000, 0.000000)]),
  335. Point(12.000000, 6.000000),
  336. Line([Point(14.000000, 4.000000), Point(14.000000, 2.000000),
  337. Point(14.000000, 0.000000)]),
  338. Point(14.000000, 6.000000)]
  339. >>> bbox = Bbox(north=20, south=18, east=20, west=18)
  340. >>> test_vect.find_by_bbox.geos(bbox=bbox)
  341. >>> bbox = Bbox(north=20, south=18, east=20, west=18)
  342. >>> test_vect.find_by_bbox.geos(bbox=bbox, bboxlist_only=True)
  343. >>> test_vect.close()
  344. """
  345. found = BoxList()
  346. if libvect.Vect_select_lines_by_box(self.c_mapinfo, bbox.c_bbox,
  347. self.vtype[type], found.c_boxlist):
  348. if bboxlist_only:
  349. return found
  350. else:
  351. return [read_line(f_id, self.c_mapinfo, self.table,
  352. self.writeable) for f_id in found.ids]
  353. @must_be_open
  354. def nodes(self, bbox):
  355. """Find the nodes inside a boundingbox.
  356. :param bbox: The boundingbox to search in
  357. :type bbox: grass.pygrass.vector.basic.Bbox
  358. :return: A list of nodes or None if nothing was found
  359. This methods uses libvect.Vect_select_nodes_by_box()
  360. Examples:
  361. >>> from grass.pygrass.vector import VectorTopo
  362. >>> from grass.pygrass.vector.basic import Bbox
  363. >>> test_vect = VectorTopo(test_vector_name)
  364. >>> test_vect.open('r')
  365. # Find nodes in box
  366. >>> bbox = Bbox(north=5, south=-1, east=15, west=9)
  367. >>> result = test_vect.find_by_bbox.nodes(bbox=bbox)
  368. >>> result
  369. [Node(2), Node(1), Node(4), Node(3), Node(5), Node(6)]
  370. >>> bbox = Bbox(north=20, south=18, east=20, west=18)
  371. >>> test_vect.find_by_bbox.nodes(bbox=bbox)
  372. >>> test_vect.close()
  373. """
  374. found = Ilist()
  375. if libvect.Vect_select_nodes_by_box(self.c_mapinfo, bbox.c_bbox,
  376. found.c_ilist):
  377. if len(found) > 0:
  378. return [Node(v_id=n_id, c_mapinfo=self.c_mapinfo,
  379. table=self.table, writeable=self.writeable)
  380. for n_id in found]
  381. @must_be_open
  382. def areas(self, bbox, boxlist=None, bboxlist_only=False):
  383. """Find the areas inside a boundingbox.
  384. :param bbox: The boundingbox to search in
  385. :type bbox: grass.pygrass.vector.basic.Bbox
  386. :param boxlist: An existing BoxList to be filled with
  387. :type_boxlist: grass.pygrass.vector.basic.BoxList
  388. :param bboxlist_only: If true the BoxList will be returned,
  389. no features are generated
  390. :type bboxlist_only: boolean
  391. :return: A list of areas or None if nothing was found
  392. This methods uses libvect.Vect_select_areas_by_box()
  393. Examples:
  394. >>> from grass.pygrass.vector import VectorTopo
  395. >>> from grass.pygrass.vector.basic import Bbox
  396. >>> test_vect = VectorTopo(test_vector_name)
  397. >>> test_vect.open('r')
  398. # Find areas in box
  399. >>> bbox = Bbox(north=5, south=-1, east=9, west=-1)
  400. >>> result = test_vect.find_by_bbox.areas(bbox=bbox)
  401. >>> result
  402. [Area(1), Area(2), Area(3), Area(4)]
  403. >>> bbox = Bbox(north=5, south=-1, east=9, west=-1)
  404. >>> result = test_vect.find_by_bbox.areas(bbox=bbox,
  405. ... bboxlist_only=True)
  406. >>> result #doctest: +NORMALIZE_WHITESPACE
  407. Boxlist([Bbox(4.0, 0.0, 4.0, 0.0),
  408. Bbox(4.0, 0.0, 6.0, 4.0),
  409. Bbox(3.0, 1.0, 3.0, 1.0),
  410. Bbox(4.0, 0.0, 8.0, 6.0)])
  411. >>> bbox = Bbox(north=20, south=18, east=20, west=18)
  412. >>> test_vect.find_by_bbox.areas(bbox=bbox)
  413. >>> test_vect.find_by_bbox.areas(bbox=bbox,
  414. ... bboxlist_only=True)
  415. >>> test_vect.close()
  416. """
  417. boxlist = boxlist if boxlist else BoxList()
  418. if libvect.Vect_select_areas_by_box(self.c_mapinfo, bbox.c_bbox,
  419. boxlist.c_boxlist):
  420. if bboxlist_only:
  421. return boxlist
  422. else:
  423. return [Area(v_id=a_id, c_mapinfo=self.c_mapinfo,
  424. table=self.table, writeable=self.writeable)
  425. for a_id in boxlist.ids]
  426. @must_be_open
  427. def islands(self, bbox, bboxlist_only=False):
  428. """Find the isles inside a boundingbox.
  429. :param bbox: The boundingbox to search in
  430. :type bbox: grass.pygrass.vector.basic.Bbox
  431. :param bboxlist_only: If true the BoxList will be returned,
  432. no features are generated
  433. :type bboxlist_only: boolean
  434. :return: A list of isles or None if nothing was found
  435. This methods uses libvect.Vect_select_isles_by_box()
  436. Examples:
  437. >>> from grass.pygrass.vector import VectorTopo
  438. >>> from grass.pygrass.vector.basic import Bbox
  439. >>> test_vect = VectorTopo(test_vector_name)
  440. >>> test_vect.open('r')
  441. # Find isles in box
  442. >>> bbox = Bbox(north=5, south=-1, east=9, west=-1)
  443. >>> result = test_vect.find_by_bbox.islands(bbox=bbox)
  444. >>> result
  445. [Isle(1), Isle(2)]
  446. >>> bbox = Bbox(north=5, south=-1, east=9, west=-1)
  447. >>> result = test_vect.find_by_bbox.islands(bbox=bbox,
  448. ... bboxlist_only=True)
  449. >>> result #doctest: +NORMALIZE_WHITESPACE
  450. Boxlist([Bbox(4.0, 0.0, 8.0, 0.0),
  451. Bbox(3.0, 1.0, 3.0, 1.0)])
  452. >>> bbox = Bbox(north=20, south=18, east=20, west=18)
  453. >>> test_vect.find_by_bbox.islands(bbox=bbox)
  454. >>> test_vect.find_by_bbox.islands(bbox=bbox,
  455. ... bboxlist_only=True)
  456. >>> test_vect.close()
  457. """
  458. found = BoxList()
  459. if libvect.Vect_select_isles_by_box(self.c_mapinfo, bbox.c_bbox,
  460. found.c_boxlist):
  461. if bboxlist_only:
  462. return found
  463. else:
  464. return [Isle(v_id=i_id, c_mapinfo=self.c_mapinfo,
  465. table=self.table, writeable=self.writeable)
  466. for i_id in found.ids]
  467. class PolygonFinder(AbstractFinder):
  468. def __init__(self, c_mapinfo, table=None, writeable=False):
  469. super(PolygonFinder, self).__init__(c_mapinfo, table, writeable)
  470. def lines(self, polygon, isles=None):
  471. pass
  472. def areas(self, polygon, isles=None):
  473. pass
  474. if __name__ == "__main__":
  475. import doctest
  476. from grass.pygrass import utils
  477. utils.create_test_vector_map(test_vector_name)
  478. doctest.testmod()
  479. """Remove the generated vector map, if exist"""
  480. from grass.pygrass.utils import get_mapset_vector
  481. from grass.script.core import run_command
  482. mset = get_mapset_vector(test_vector_name, mapset='')
  483. if mset:
  484. run_command("g.remove", flags='f', type='vector', name=test_vector_name)