[GRASS-dev] [GRASS GIS] #2413: pygrass: number_of wrong function associated

#2413: pygrass: number_of wrong function associated
-------------------------+--------------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
In _NUMOF dictionary (pygrass/vector/__init__.py )'lines' key is
associated to libvect.Vect_get_num_line_points function instead of
libvect.Vect_get_num_lines

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2413&gt;
GRASS GIS <http://grass.osgeo.org>

#2413: pygrass: number_of wrong function associated
-------------------------+--------------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by lucadelu):

Replying to [ticket:2413 artegion]:
> In _NUMOF dictionary (pygrass/vector/__init__.py )'lines' key is
associated to libvect.Vect_get_num_line_points function instead of
libvect.Vect_get_num_lines
>

Fixed in r61862.
If it is correct it should be backported.

Thanks

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2413#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2413: pygrass: number_of wrong function associated
----------------------------+-----------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: pygrass vector | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------
Changes (by zarch):

  * keywords: => pygrass vector

Comment:

Replying to [comment:1 lucadelu]:
> Replying to [ticket:2413 artegion]:
> > In _NUMOF dictionary (pygrass/vector/__init__.py )'lines' key is
associated to libvect.Vect_get_num_line_points function instead of
libvect.Vect_get_num_lines
> >
>
> Fixed in r61862.
> If it is correct it should be backported.

Mmh, I'm still not convinced running the code below on NC:

{{{
from pprint import pprint
from grass.pygrass.vector import VectorTopo
from grass.pygrass.vector import _NUMOF
from grass.pygrass.modules.shortcuts import vector as v

def test_vect_features(vectname):
     print(vectname)
     with VectorTopo(vectname, mode='r') as vect:
         for key in sorted(_NUMOF):
             print(" %20s %6d" % (key, vect.number_of('points')))
         print(' primitives:')
         pprint(vect.num_primitives())
         v.info(vectname)
     print

test_vect_features('schools')
test_vect_features('streams')
}}}

_NUMOF is defined
(http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/pygrass/vector/__init__.py#L24):

{{{
_NUMOF = {"areas": libvect.Vect_get_num_areas,
           "dblinks": libvect.Vect_get_num_dblinks,
           "faces": libvect.Vect_get_num_faces,
           "holes": libvect.Vect_get_num_holes,
           "islands": libvect.Vect_get_num_islands,
           "kernels": libvect.Vect_get_num_kernels,
           "lines": libvect.Vect_get_num_lines,
           "points": libvect.Vect_get_num_line_points,
           "nodes": libvect.Vect_get_num_nodes,
           "updated_lines": libvect.Vect_get_num_updated_lines,
           "updated_nodes": libvect.Vect_get_num_updated_nodes,
           "volumes": libvect.Vect_get_num_volumes}
}}}

And this is what I got:

{{{
schools
                  areas 5
                dblinks 5
                  faces 5
                  holes 5
                islands 5
                kernels 5
                  lines 5
                  nodes 5
                 points 5
          updated_lines 5
          updated_nodes 5
                volumes 5
   primitives:
{'area': 0,
  'boundary': 0,
  'centroid': 0,
  'face': 0,
  'kernel': 0,
  'line': 0,
  'point': 167,
  'volume': 0}
+----------------------------------------------------------------------------+
  | Name: schools
|
  | Mapset: PERMANENT
|
  | Location: nc_basic_spm_grass7
|
  | Database: /home/pietro/docdat/gis
|
  | Title: Wake County schools (points map)
|
  | Map scale: 1:1
|
  | Name of creator: helena
|
  | Organization: NC OneMap
|
  | Source date: Tue Nov 7 19:34:09 2006
|
  | Timestamp (first layer): none
|
|----------------------------------------------------------------------------|
  | Map format: native
|
|----------------------------------------------------------------------------|
  | Type of map: vector (level: 2)
|
  |
|
  | Number of points: 167 Number of centroids: 0
|
  | Number of lines: 0 Number of boundaries: 0
|
  | Number of areas: 0 Number of islands: 0
|
  |
|
  | Map is 3D: No
|
  | Number of dblinks: 1
|
  |
|
  | Projection: Lambert Conformal Conic
|
  |
|
  | N: 248159.84441077 S: 203559.01136227
|
  | E: 671714.55110786 W: 619215.13388253
|
  |
|
  | Digitization threshold: 0
|
  | Comment:
|
  |
|
+----------------------------------------------------------------------------+

streams
                  areas 5
                dblinks 5
                  faces 5
                  holes 5
                islands 5
                kernels 5
                  lines 5
                  nodes 5
                 points 5
          updated_lines 5
          updated_nodes 5
                volumes 5
   primitives:
{'area': 0,
  'boundary': 0,
  'centroid': 0,
  'face': 0,
  'kernel': 0,
  'line': 8554,
  'point': 0,
  'volume': 0}
+----------------------------------------------------------------------------+
  | Name: streams
|
  | Mapset: PERMANENT
|
  | Location: nc_basic_spm_grass7
|
  | Database: /home/pietro/docdat/gis
|
  | Title: South-West Wake streams (lines map)
|
  | Map scale: 1:1
|
  | Name of creator: helena
|
  | Organization: NC OneMap
|
  | Source date: Tue Nov 7 19:37:02 2006
|
  | Timestamp (first layer): none
|
|----------------------------------------------------------------------------|
  | Map format: native
|
|----------------------------------------------------------------------------|
  | Type of map: vector (level: 2)
|
  |
|
  | Number of points: 0 Number of centroids: 0
|
  | Number of lines: 8554 Number of boundaries: 0
|
  | Number of areas: 0 Number of islands: 0
|
  |
|
  | Map is 3D: No
|
  | Number of dblinks: 1
|
  |
|
  | Projection: Lambert Conformal Conic
|
  |
|
  | N: 228882.03322323 S: 214637.98658874
|
  | E: 645264.23103886 W: 629851.88519177
|
  |
|
  | Digitization threshold: 0
|
  | Comment:
|
  |
|
+----------------------------------------------------------------------------+
}}}

So it is not clear to me what is not working, but I don't think that it is
correct...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2413#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2413: pygrass: number_of wrong function associated
----------------------------+-----------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: pygrass vector | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by lucadelu):

Replying to [comment:2 zarch]:
> Replying to [comment:1 lucadelu]:
>
> Mmh, I'm still not convinced running the code below on NC:
>

maybe the test_vect_features is wrong, I changed as this

{{{
def test_vect_features(vectname):
     print(vectname)
     with VectorTopo(vectname, mode='r') as vect:
         for key in sorted(_NUMOF):
             print(" %20s %6d" % (key, vect.number_of(key)))
         print(' primitives:')
         pprint(vect.num_primitives())
         v.info(vectname)
     print
}}}

this is mine output

{{{

schools
                  areas 0
                dblinks 1
                  faces 0
                  holes 0
                islands 0
                kernels 0
                  lines 167
                  nodes 0
                 points 5
          updated_lines 0
          updated_nodes 0
                volumes 0
   primitives:
{'area': 0,
  'boundary': 0,
  'centroid': 0,
  'face': 0,
  'kernel': 0,
  'line': 0,
  'point': 167,
  'volume': 0}
+----------------------------------------------------------------------------+
  | Name: schools
|
  | Mapset: PERMANENT
|
  | Location: nc_basic_spm_grass7
|
  | Database: /home/lucadelu/grassdata
|
  | Title: Wake County schools (points map)
|
  | Map scale: 1:1
|
  | Name of creator: helena
|
  | Organization: NC OneMap
|
  | Source date: Tue Nov 7 19:34:09 2006
|
  | Timestamp (first layer): none
|
|----------------------------------------------------------------------------|
  | Map format: native
|
|----------------------------------------------------------------------------|
  | Type of map: vector (level: 2)
|
  |
|
  | Number of points: 167 Number of centroids: 0
|
  | Number of lines: 0 Number of boundaries: 0
|
  | Number of areas: 0 Number of islands: 0
|
  |
|
  | Map is 3D: No
|
  | Number of dblinks: 1
|
  |
|
  | Projection: Lambert Conformal Conic
|
  |
|
  | N: 248159.84441077 S: 203559.01136227
|
  | E: 671714.55110786 W: 619215.13388253
|
  |
|
  | Digitization threshold: 0
|
  | Comment:
|
  |
|
+----------------------------------------------------------------------------+

streams
                  areas 0
                dblinks 1
                  faces 0
                  holes 0
                islands 0
                kernels 0
                  lines 8554
                  nodes 8645
                 points 5
          updated_lines 0
          updated_nodes 0
                volumes 0
   primitives:
{'area': 0,
  'boundary': 0,
  'centroid': 0,
  'face': 0,
  'kernel': 0,
  'line': 8554,
  'point': 0,
  'volume': 0}
+----------------------------------------------------------------------------+
  | Name: streams
|
  | Mapset: PERMANENT
|
  | Location: nc_basic_spm_grass7
|
  | Database: /home/lucadelu/grassdata
|
  | Title: South-West Wake streams (lines map)
|
  | Map scale: 1:1
|
  | Name of creator: helena
|
  | Organization: NC OneMap
|
  | Source date: Tue Nov 7 19:37:02 2006
|
  | Timestamp (first layer): none
|
|----------------------------------------------------------------------------|
  | Map format: native
|
|----------------------------------------------------------------------------|
  | Type of map: vector (level: 2)
|
  |
|
  | Number of points: 0 Number of centroids: 0
|
  | Number of lines: 8554 Number of boundaries: 0
|
  | Number of areas: 0 Number of islands: 0
|
  |
|
  | Map is 3D: No
|
  | Number of dblinks: 1
|
  |
|
  | Projection: Lambert Conformal Conic
|
  |
|
  | N: 228882.03322323 S: 214637.98658874
|
  | E: 645264.23103886 W: 629851.88519177
|
  |
|
  | Digitization threshold: 0
|
  | Comment:
|
  |
|
+----------------------------------------------------------------------------+

}}}

> So it is not clear to me what is not working, but I don't think that it
is correct...
>

It seems better, but it is still strange the result of schools map
(lines=167,points=5)

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2413#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2413: pygrass: number_of wrong function associated
----------------------------+-----------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: pygrass vector | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by lucadelu):

Replying to [comment:3 lucadelu]:

>
> It seems better, but it is still strange the result of schools map
(lines=167,points=5)

Reading the documentation it is more clear, the description of function
''Vect_get_num_lines'' is:

{{{
Fetch number of features (points, lines, boundaries, centroids) in vector
map
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2413#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2413: pygrass: number_of wrong function associated
----------------------------+-----------------------------------------------
Reporter: artegion | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.5
Component: Python | Version: svn-releasebranch70
Keywords: pygrass vector | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by artegion):

Replying to [comment:4 lucadelu]:
> Replying to [comment:3 lucadelu]:
>
> >
> > It seems better, but it is still strange the result of schools map
(lines=167,points=5)
>
> Reading the documentation it is more clear, the description of function
''Vect_get_num_lines'' is:
>
> {{{
> Fetch number of features (points, lines, boundaries, centroids) in
vector map
> }}}

It seems wrong use of '''Vect_get_num_line_points''' function in _NUMOF.
Vect_get_num_line_points: Get number of line points and takes a pointer to
line_pnts structure (not a pointer to Map_info struct).[[BR]]

the correct form of _NUMOF shoud be
{{{
_NUMOF = {"areas": libvect.Vect_get_num_areas,
           "dblinks": libvect.Vect_get_num_dblinks,
           "faces": libvect.Vect_get_num_faces,
           "holes": libvect.Vect_get_num_holes,
           "islands": libvect.Vect_get_num_islands,
           "kernels": libvect.Vect_get_num_kernels,
           "lines": libvect.Vect_get_num_lines,
           "nodes": libvect.Vect_get_num_nodes,
           "updated_lines": libvect.Vect_get_num_updated_lines,
           "updated_nodes": libvect.Vect_get_num_updated_nodes,
           "volumes": libvect.Vect_get_num_volumes}

}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2413#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>