GeoTools
  1. GeoTools
  2. GEOT-455

VPF not always setting default geometry

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.M3
    • Fix Version/s: 2.7-M0
    • Component/s: vpf plugin
    • Labels:
      None

      Description

      With VMap0 there are many cases where a default geometry is not set on a feature even though there is a geometry attribute in the feature. The attached program will illustrate the problem when run against VMap0 data (tested against EURNASIA Ed: 003). Below is a small sample of the output of this program:

      Default Geometry is null for: Feature[ id=fid-17f1ba3:1026a8cc89f:-77f4 , id=2 , f_code=BA010 , edg_id=2 , libref.lft_id=2 , start_node=2 , end_node=3 , right_edge=2 , left_edge=3 , coordinates=LINESTRING (58.7053337097168 81.62566375732422, 58.716251373291016 81.62711334228516) ]
      Default Geometry is null for: Feature[ id=fid-17f1ba3:1026a8cc89f:-77f1 , id=3 , f_code=BA010 , edg_id=3 , libref.lft_id=3 , start_node=2 , end_node=2 , right_edge=2 , left_edge=3 , coordinates=LINESTRING (58.7053337097168 81.62566375732422, 58.67924880981445 81.63772583007812, 58.60916519165039 81.6314697265625, 58.43180465698242 81.62972259521484, 58.3837776184082 81.62750244140625, 58.35672378540039 81.6225814819336, 58.374916076660156 81.61708068847656, 58.399417877197266 81.61402893066406, 58.38569259643555 81.61111450195312, 58.33102798461914 81.60800170898438, 58.31819534301758 81.60441589355469, 58.29891586303711 81.58858489990234, 58.30983352661133 81.58380889892578, 58.34105682373047 81.5816421508789, 58.395084381103516 81.58069610595703, 58.44449996948242 81.579833984375, 58.50180435180664 81.5770034790039, 58.53069305419922 81.57661437988281, 58.56594467163086 81.57869720458984, 58.60122299194336 81.58335876464844, 58.62052917480469 81.58941650390625, 58.69497299194336 81.59441375732422, 58.73447036743164 81.60724639892578, 58.7053337097168 81.62566375732422) ]

        Activity

        Hide
        John Meagher added a comment -
        Attaching the file failed, so here's the mentioned program:

        import java.io.File;

        import org.geotools.data.DataStore;
        import org.geotools.data.FeatureReader;
        import org.geotools.data.FeatureResults;
        import org.geotools.data.FeatureSource;
        import org.geotools.feature.Feature;

        import com.vividsolutions.jts.geom.Geometry;

        public class VPFRunThrough
        {
          public static void main( String[] args )
            throws Exception
          {
            if ( args.length != 1 )
            {
              System.err.println( "Usage: java " + VPFRunThrough.class.getName() + " <VPF directory containing lht file>" );
              System.exit( 1 );
            }

            DataStore ds = new org.geotools.data.vpf.VPFLibrary( new File( args[0] ) );
            String[] types = ds.getTypeNames();
            for ( int i = 0; i < types.length; i++ )
              runThrough( ds, types[i] );
          }

          static void runThrough( DataStore ds, String feature )
            throws Exception
          {
            FeatureReader fr = null;
            try
            {
              FeatureSource fs = ds.getFeatureSource( feature );
              FeatureResults res = fs.getFeatures();
              fr = res.reader();
              while ( fr.hasNext() )
              {
                Feature f = fr.next();
                Geometry g = f.getDefaultGeometry();
                if ( g == null )
                  System.out.println( "Default Geometry is null for: " + f );
              }
            }
            finally
            {
              if ( fr != null ) fr.close();
            }
          }
        }
          
        Show
        John Meagher added a comment - Attaching the file failed, so here's the mentioned program: import java.io.File; import org.geotools.data.DataStore; import org.geotools.data.FeatureReader; import org.geotools.data.FeatureResults; import org.geotools.data.FeatureSource; import org.geotools.feature.Feature; import com.vividsolutions.jts.geom.Geometry; public class VPFRunThrough {   public static void main( String[] args )     throws Exception   {     if ( args.length != 1 )     {       System.err.println( "Usage: java " + VPFRunThrough.class.getName() + " <VPF directory containing lht file>" );       System.exit( 1 );     }     DataStore ds = new org.geotools.data.vpf.VPFLibrary( new File( args[0] ) );     String[] types = ds.getTypeNames();     for ( int i = 0; i < types.length; i++ )       runThrough( ds, types[i] );   }   static void runThrough( DataStore ds, String feature )     throws Exception   {     FeatureReader fr = null;     try     {       FeatureSource fs = ds.getFeatureSource( feature );       FeatureResults res = fs.getFeatures();       fr = res.reader();       while ( fr.hasNext() )       {         Feature f = fr.next();         Geometry g = f.getDefaultGeometry();         if ( g == null )           System.out.println( "Default Geometry is null for: " + f );       }     }     finally     {       if ( fr != null ) fr.close();     }   } }   
        Hide
        Michael Bedward added a comment -
        VPF module no longer supported
        Show
        Michael Bedward added a comment - VPF module no longer supported

          People

          • Assignee:
            Unassigned
            Reporter:
            John Meagher
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: