Expecting (',') but got a ']' in V2.0

Oct 2, 2007 at 9:01 AM
Hi,

as suggested by blackrussian, I've tried to load an *shp file with the index.
If it's right, my modification is in the given WinForm example in ShapeFileLayerFactory class:

ShapeFileProvider shapeFileData = new ShapeFileProvider(connectionInfo, true); // add true as second parameter

After this modification I got the descibed exception: Expecting (',') but got a ']' at line 1 column 426.

Here is call stack:
> SharpMap.dll!SharpMap.Data.Providers.ShapeFile.ShapeFileProvider.Open(bool exclusive = false) Zeile 819 C#
SharpMap.dll!SharpMap.Data.Providers.ShapeFile.ShapeFileProvider.Open() Zeile 778 + 0x9 Bytes C#
SharpMap.dll!SharpMap.Layers.FeatureLayer.FeatureLayer(string layername = "gewaesserflaechen", SharpMap.Styles.VectorStyle style = {SharpMap.Styles.VectorStyle}, SharpMap.Data.IFeatureLayerProvider dataSource = {ShapeFile Name: G:\AL\Develop\CsharpProgs\WinFormsSharpMap\WinFormsSharpMap\WinFormsSharpMap\bin\Debug\frida-1.0.1-shp-joined\gewaesserflaechen.shp; HasDbf: True; Features: 160; Extents: BoundingBox Lower Left: (3.427.433,65, 5.789.186,61) Upper Right: (3.443.808,18, 5.800.377,06)}, bool handleFeatureDataRequest = true) Zeile 104 + 0x11 Bytes C#
SharpMap.dll!SharpMap.Layers.FeatureLayer.FeatureLayer(string layername = "gewaesserflaechen", SharpMap.Styles.VectorStyle style = {SharpMap.Styles.VectorStyle}, SharpMap.Data.IFeatureLayerProvider dataSource = {ShapeFile Name: G:\AL\Develop\CsharpProgs\WinFormsSharpMap\WinFormsSharpMap\WinFormsSharpMap\bin\Debug\frida-1.0.1-shp-joined\gewaesserflaechen.shp; HasDbf: True; Features: 160; Extents: BoundingBox Lower Left: (3.427.433,65, 5.789.186,61) Upper Right: (3.443.808,18, 5.800.377,06)}) Zeile 84 + 0x11 Bytes C#
SharpMap.dll!SharpMap.Layers.GeometryLayer.GeometryLayer(string layername = "gewaesserflaechen", SharpMap.Styles.VectorStyle style = {SharpMap.Styles.VectorStyle}, SharpMap.Data.IFeatureLayerProvider dataSource = {ShapeFile Name: G:\AL\Develop\CsharpProgs\WinFormsSharpMap\WinFormsSharpMap\WinFormsSharpMap\bin\Debug\frida-1.0.1-shp-joined\gewaesserflaechen.shp; HasDbf: True; Features: 160; Extents: BoundingBox Lower Left: (3.427.433,65, 5.789.186,61) Upper Right: (3.443.808,18, 5.800.377,06)}) Zeile 63 + 0xf Bytes C#
SharpMap.dll!SharpMap.Layers.GeometryLayer.GeometryLayer(string layername = "gewaesserflaechen", SharpMap.Data.IFeatureLayerProvider dataSource = {ShapeFile Name: G:\AL\Develop\CsharpProgs\WinFormsSharpMap\WinFormsSharpMap\WinFormsSharpMap\bin\Debug\frida-1.0.1-shp-joined\gewaesserflaechen.shp; HasDbf: True; Features: 160; Extents: BoundingBox Lower Left: (3.427.433,65, 5.789.186,61) Upper Right: (3.443.808,18, 5.800.377,06)}) Zeile 52 + 0x20 Bytes C#
DemoWinForm.exe!DemoWinForm.ShapeFileLayerFactory.Create(string layerName = "gewaesserflaechen", string connectionInfo = "G:\\AL\\Develop\\CsharpProgs\\WinFormsSharpMap\\WinFormsSharpMap\\WinFormsSharpMap\\bin\\Debug\\frida-1.0.1-shp-joined\\gewaesserflaechen.shp") Zeile 30 + 0x18 Bytes C#
DemoWinForm.exe!DemoWinForm.MainForm.loadLayer() Zeile 72 + 0xd Bytes C#
DemoWinForm.exe!DemoWinForm.MainForm.AddLayerToolStripButton_Click.AnonymousMethod() Zeile 173 + 0x8 Bytes C#
Externer Code
DemoWinForm.exe!DemoWinForm.Program.Main() Zeile 33 + 0x1a Bytes C#
Externer Code


Now, I don't undestand, how to do this right manner and load a ShapeFile...

Thanks for any help!
Oct 6, 2007 at 7:17 PM
Hi,

any improvements with this issue or will be this fixed in rev 232?

Thanks in advive.
Oct 7, 2007 at 4:26 AM
This sounds like an error thrown by the WKT parser. Do you have a .prj file together with your .shp file? Check whats in column 426 of that file, this might give you a clue about whats wrong. Feel free to paste the WKT string here too. This might be a bug in the parser
Oct 7, 2007 at 2:09 PM
Hi,

in column 426 of which file? *.sph. *.sph.sidx, *.prj? SPH file looks like a binary file, I don't can say, where is column 426.
It#s possible to attach files to discussion, otherwise I can give link to the interner source.

Moreover, I had not the problem with V0.9 with same files.
Because of it, I think, the problem is specifical for V2.0 parser implementation, my be some localisation issues.

It would be great, if it will works again. Possible to move to issue tracker for Beta1 of V2.0?

Thanks.
Oct 8, 2007 at 12:49 AM
I was talking about the contents of the .prj file which is a text file.
If this is a problem in the WKT parser, the problem is with Proj.NET and not SharpMap.
Post the contents of the file here, and I will confirm.

As a temporary workaround, remove the PRJ file and see if that helps. If there is no .prj file, sharpmap will not try and attach a spatial reference to the datasource.
Oct 9, 2007 at 10:06 AM
Edited Oct 9, 2007 at 10:14 AM
Yes, it's the problem with *.prj files. After removing these, demo will work again.
Here is the content of the file:

PROJCS["Transverse Mercator",GEOGCS["bessel",DATUM["Deutsches_Hauptdreiecksnetz",SPHEROID["bessel",6377397.155,299.1528128],TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.70]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",1],PARAMETER["false_easting",3500000],PARAMETER["false_northing",0]]


The size of the file is exactly 426 bytes. But the last both symbols are not only an ']' followed by a second ']', after both this symbols there is a last symbol with hexadecimal code 0A. I've tried to remove this last symbol from all *.prf files in the directory, but this does not help.

And you make right decision, the problem is in WKT parser. Now I post snap in from JIT-Debugger, and we can see the exception from WKT Tokenizer:

SharpMap.Converters.ParseException: Expecting (',') but got a ']' at line 1 column 426.
bei SharpMap.Converters.WellKnownText.WktStreamTokenizer.ReadToken(String expectedToken) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Converters\WellKnownText\WKTStreamTokenizer.cs:Zeile 81.
bei SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.ReadProjection(WktStreamTokenizer tokenizer) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Converters\WellKnownText\CoordinateSystemWktReader.cs:Zeile 363.
bei SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.ReadProjectedCoordinateSystem(WktStreamTokenizer tokenizer) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Converters\WellKnownText\CoordinateSystemWktReader.cs:Zeile 407.
bei SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.ReadCoordinateSystem(String coordinateSystem, WktStreamTokenizer tokenizer) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Converters\WellKnownText\CoordinateSystemWktReader.cs:Zeile 208.
bei SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.Parse(String wkt) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Converters\WellKnownText\CoordinateSystemWktReader.cs:Zeile 88.
bei SharpMap.Data.Providers.ShapeFile.ShapeFileProvider.parseProjection() in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Data\Providers\Shapefile\ShapeFileProvider.cs:Zeile 2246.
bei SharpMap.Data.Providers.ShapeFile.ShapeFileProvider.Open(Boolean exclusive) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Data\Providers\Shapefile\ShapeFileProvider.cs:Zeile 743.
bei SharpMap.Data.Providers.ShapeFile.ShapeFileProvider.Open() in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Data\Providers\Shapefile\ShapeFileProvider.cs:Zeile 700.
bei SharpMap.Layers.FeatureLayer..ctor(String layername, VectorStyle style, IFeatureLayerProvider dataSource, Boolean handleFeatureDataRequest) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Layers\FeatureLayer.cs:Zeile 107.
bei SharpMap.Layers.FeatureLayer..ctor(String layername, VectorStyle style, IFeatureLayerProvider dataSource) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Layers\FeatureLayer.cs:Zeile 87.
bei SharpMap.Layers.GeometryLayer..ctor(String layername, VectorStyle style, IFeatureLayerProvider dataSource) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Layers\GeometryLayer.cs:Zeile 63.
bei SharpMap.Layers.GeometryLayer..ctor(String layername, IFeatureLayerProvider dataSource) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\SharpMap\Layers\GeometryLayer.cs:Zeile 52.
bei DemoWinForm.ShapeFileLayerFactory.Create(String layerName, String connectionInfo) in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\DemoWinForm\ShapeFileLayerFactory.cs:Zeile 30.
bei DemoWinForm.MainForm.loadLayer() in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\DemoWinForm\MainForm.cs:Zeile 88.
bei DemoWinForm.MainForm.<AddLayerToolStripButtonClick>b_0() in G:\AL\Develop\CsharpProgs\WinFormsSharpMap2\SharpMap2\DemoWinForm\MainForm.cs:Zeile 189.
bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
bei System.Threading.ExecutionContext.runTryCode(Object userData)
bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbacks()


Geladene Assemblys :
mscorlib
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll.
----------------------------------------
DemoWinForm
Assembly-Version: 1.0.0.0.
Win32-Version: 1.0.0.0.
CodeBase: file:///G:/AL/Develop/CsharpProgs/WinFormsSharpMap2/SharpMap2/DemoWinForm/bin/Debug/DemoWinForm.exe.
----------------------------------------
System.Windows.Forms
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Windows.Forms/2.0.0.0_b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System/2.0.0.0_b77a5c561934e089/System.dll.
----------------------------------------
System.Drawing
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Drawing/2.0.0.0_b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
SharpMap
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.0.0.
CodeBase: file:///G:/AL/Develop/CsharpProgs/WinFormsSharpMap2/SharpMap2/DemoWinForm/bin/Debug/SharpMap.DLL.
----------------------------------------
NPack
Assembly-Version: 0.7.8392.0.
Win32-Version: 0.7.8392.0.
CodeBase: file:///G:/AL/Develop/CsharpProgs/WinFormsSharpMap2/SharpMap2/DemoWinForm/bin/Debug/NPack.DLL.
----------------------------------------
SharpMap.Presentation.WinForms
Assembly-Version: 1.0.0.0.
Win32-Version: 1.0.0.0.
CodeBase: file:///G:/AL/Develop/CsharpProgs/WinFormsSharpMap2/SharpMap2/DemoWinForm/bin/Debug/SharpMap.Presentation.WinForms.DLL.
----------------------------------------
System.Data
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GAC32/System.Data/2.0.0.0_b77a5c561934e089/System.Data.dll.
----------------------------------------
System.Xml
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Xml/2.0.0.0_b77a5c561934e089/System.Xml.dll.
----------------------------------------
System.Configuration
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Configuration/2.0.0.0_b03f5f7f11d50a3a/System.Configuration.dll.
----------------------------------------
System.Windows.Forms.resources
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/assembly/GACMSIL/System.Windows.Forms.resources/2.0.0.0de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------
SharpMap.Rendering.Gdi
Assembly-Version: 1.0.0.0.
Win32-Version: 1.0.0.0.
CodeBase: file:///G:/AL/Develop/CsharpProgs/WinFormsSharpMap2/SharpMap2/DemoWinForm/bin/Debug/SharpMap.Rendering.Gdi.DLL.
----------------------------------------
mscorlib.resources
Assembly-Version: 2.0.0.0.
Win32-Version: 2.0.50727.1378 (REDBITSB2.050727-1300).
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll.
----------------------------------------

Possible to move the thread in Proj.NET?

Thanks.
Oct 10, 2007 at 7:40 AM
Edited Oct 10, 2007 at 7:41 AM
Your WKT is incorrect. It's required to have a linear unit at the end of the parameter list - See here
Add this just before the last closing bracket:
,UNIT["Metre",1.0]

Without it the projection doesn't make any sense.


This is just a guess (I don't know the german systems that well), but I think the correct full WKT for this projection including authorities is:
PROJCS["DHDN / Gauss-Kruger zone 3",
    GEOGCS["DHDN",
        DATUM["Deutsches_Hauptdreiecksnetz",
            SPHEROID["Bessel 1841",6377397.155,299.1528128000008,AUTHORITY["EPSG","7004"]],
            TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.70],
            AUTHORITY["EPSG","6314"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4314"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",3500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","31493"]
]
Oct 10, 2007 at 8:08 AM
Hi!

Many thanks! I'm not a GIS guy at all, only software developer, because of it I know nothing about file structures.
For some small project I doing the tests with some GIS-systems. For a long time the test were done for V0.9 with some randomly files. The used files are from official site. Interesting is, that it works with V0.9. I think, I post your correction to the administrator of this site.