[問題] GDAL/OGR 讀 S-57 格式檔案的問題
最近在嘗試用C#讀S-57格式的檔案
用的是由
http://download.osgeo.org/gdal/
下載的gdal source code
也有試過搭用FW Tools 2.4.7
http://fwtools.maptools.org/
我試著把裏面的ogrinfo.cs make 起來
但是執行的結果不如預期..
我用的環境是VS 2005
ogr相關的dll, 我試過拿gdal source make出來的 gdal_csharp.dll 等九個dll
或是把FW Tools裏的直接拿來用, 都有一樣問題..
不知有沒有先進有遇過一樣的問題
我執行的source code如下:
using System;
using System.Collections.Generic;
using System.Text;
using OSGeo.OGR;
using OSGeo.OSR;
namespace ogrinfo
{
class OGRInfo
{
public static void usage()
{
Console.WriteLine("usage: ogrinfo {data source name}");
System.Environment.Exit(-1);
}
public static void Main(string[] args)
{
if (args.Length != 1) usage();
// Using early initialization of System.Console
Console.WriteLine("");
/*
-------------------------------------------------------------------- */
/* Register format(s).
*/
/*
-------------------------------------------------------------------- */
Ogr.RegisterAll();
/*
-------------------------------------------------------------------- */
/* Open data source.
*/
/*
-------------------------------------------------------------------- */
DataSource ds = Ogr.Open(args[0], 0);
if (ds == null)
{
Console.WriteLine("Can't open " + args[0]);
System.Environment.Exit(-1);
}
/*
-------------------------------------------------------------------- */
/* Get driver
*/
/*
-------------------------------------------------------------------- */
Driver drv = ds.GetDriver();
if (drv == null)
{
Console.WriteLine("Can't get driver.");
System.Environment.Exit(-1);
}
// TODO: drv.name is still unsafe with lazy initialization (Bug
1339)
Console.WriteLine("Using driver " + drv.name);
/*
-------------------------------------------------------------------- */
/* Iterating through the layers
*/
/*
-------------------------------------------------------------------- */
for (int iLayer = 0; iLayer < ds.GetLayerCount(); iLayer++)
{
Layer layer = ds.GetLayerByIndex(iLayer);
if (layer == null)
{
Console.WriteLine("FAILURE: Couldn't fetch advertised
layer " + iLayer);
System.Environment.Exit(-1);
}
Console.WriteLine(layer.GetName());
//ReportLayer(layer);
}
}
}
主要會執行到的code我標了一下顏色了..
執行結果是
Using driver S57
DSID
Point
Line
Area
Meta
ds.GetLayerCount() 只傳回 5, 只有5個layer
layer的Name印出來就只有 DSID/Point/Line/Area/Meta 這五個
但是如果是用FW_Tools裏或是gdal自己make出來的
就可以讀到如下比較完整的layer
using driver `S57' successful.
1: DSID (None)
2: ACHARE
3: BCNSPP (Point)
4: BRIDGE
5: BUISGL
6: BUAARE
7: BOYSPP (Point)
8: CBLSUB (Line String)
9: COALNE (Line String)
10: DEPARE
11: DEPCNT (Line String)
12: DOCARE (Polygon)
13: DRYDOC (Polygon)
14: FSHFAC
15: HRBARE (Polygon)
16: HRBFAC
17: LAKARE (Polygon)
18: LNDARE
19: LNDELV
20: LNDMRK
21: LIGHTS (Point)
22: MORFAC
23: OBSTRN
24: PILBOP
25: RTPBCN (Point)
26: RDOSTA (Point)
27: RAILWY (Line String)
28: RESARE (Polygon)
29: RIVERS
30: ROADWY
31: SBDARE
32: SLCONS
33: SISTAT (Point)
34: SISTAW (Point)
35: SOUNDG (3D Multi Point)
36: TOPMAR (Point)
37: TSSBND (Line String)
38: TSSLPT (Polygon)
39: TSEZNE (Polygon)
40: TUNNEL
41: UWTROC (Point)
42: WATTUR
43: WRECKS
44: TS_FEB
45: M_COVR (Polygon)
46: M_NSYS (Polygon)
47: M_QUAL (Polygon)
48: C_AGGR (None)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.124.122.57