Shapefile opening failure

Hi @pmeems,

I have MapWinGIS 4.9.5.0 installed.
With “MapWinGIS.Shapefile.Open” method I am trying to open a shapefile, which has only ‘ShapeType.MULTI_PATCH’ shapes.
However the ‘Open’ method fails.
I can open the file with no issues in QGIS 3.10.2.

Does Shapefile class support MULTI_PATCH shapes?
Here is the shapefile:

And help would be appreciated.

Best regards,
George

Hello @george

MULTIPATCH Shapefile types aren’t supported by MapWinGIS. That said, MapWinGIS uses GDAL to load many of the vector file types, and the GDAL Shapefile driver says it supports MultiPatch, but that it will turn them into TINs (which I know nothing about). But the point is that you might be able to use GDAL, opening the file as an OgrLayer rather than opening as a simple Shapefile. What happens after that I don’t know, but you could try it out and see what happens.

Perhaps others have more experience with this.

Regards,
Jerry.

Thank you @jerryfaust,
Is there some rough example code that I can follow for the OgrLayer opening of the shapefile?
I’ve never used this class.

Hello @george

If you declare an OgrLayer and call OpenFromFile, passing in the name of a Shapefile, OGR will use it’s Shapefile driver to open the file. What happens after that in terms of converting to a TIN, I’m not sure, but I would then just try adding the layer to the map. In c# it would be something like:

OgrLayer ogr = new OgrLayer();
if (ogr.OpenFromFile(pathToShapefile, false))
{
    axMap1.AddLayer(ogr, true);
}

If I have more time later this week, I could try the file you uploaded. But for, try what I’ve recommended and see what happens.

Regards,
Jerry.

1 Like

Thank you @jerryfaust,

How do you instantiate the “axMap1”?
axMap axMap1 = new axMap();
If so, then when I add the ‘ogr’ to ‘AddLayer’ I get the following error message:

Runtime error (COMException): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

I tried using the Utils.OGRLayerToShapefile method instead.
It opens the shapefile, reprojects it, reads the fields without issues, but reports that the shape inside of it is of “SHP_NULL” type. Which means I can not read it.

Hello @george

2 things:

  1. I assumed you were loading the OCX onto a Form, at which point Visual Studio will generally name it axMap1. That’s where the variable would come from. But that’s ok, you don’t have to have the control loaded in order to be able to open a layer/shapefile.

  2. Regarding SHP_NULLSHAPE, I’ve seen this with OGR layers, and I’m not sure why it happens, but here’s what I do whenever I open an OGR layer (in VB.NET):

     ' ActiveShapeType defaults to NULL, we need to set it
     If pOgrLayer.ActiveShapeType = ShpfileType.SHP_NULLSHAPE AndAlso UBound(pOgrLayer.AvailableShapeTypes) >= 0 Then
         pOgrLayer.ActiveShapeType = pOgrLayer.AvailableShapeTypes(0)
     End If
    

See if that helps.

Jerry.

Addendum: Regarding the NULL shape, it may be that the shape type is NULL because it is no longer a valid Shapefile, since GDAL says it converts it to a TIN. Again, this is new territory for me, so I don’t know the answer. I will try to step through the process later this week, using your file, to see what is happening.

1 Like

Hi @jerryfaust,

Thank you once again for the help.
pOgrLayer.ActiveShapeType returns 0, and pOgrLayer.AvailableShapeTypes returns an array with only 0.

If there is something more that you discovered, I would be quite grateful to hear it.

Hello @george

I would like to try loading your shapefile and see what is happening.

If you don’t mind, could you upload the shapefile to this website. It may well be ok, but Norton is giving me severe warnings about the GoFile website.

Thank you.
Jerry.

Hi @jerryfaust,

Here it is. Thank you.
multi_patch_shapefile.zip (1.2 KB)

Hello @george

So far, no success.

I can open the file through GDAL, as an OGR Layer. And according to GDAL documentation, it is converted to a TIN file. But I don’t know what to do with it after that, at least from a MapWinGIS standpoint. Although it loads into the map, it is at that point interpreted as a Shapefile having a NULL shape type, so nothing appears.

I tried various methods of converting it or interpreting it as a MapWInGIS TIN, but to no avail.
I will have to do more research regarding how others use GDAL to read MultiPatch files.

I’ll let you know if I learn anything.

Regards,
Jerry.

1 Like

Thanks for the effort @jerryfaust.

Interestingly, I can unpack the file using the OGRINFO application that comes with the GDAL distribution, and I can get the WKT version of your shapefile, as follows:

GEOMETRYCOLLECTION Z (TIN Z (((11.343041518345 44.4938875871233 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292,11.343041518345 44.4938875871233 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.3430336701609 44.4936916889913 11.2417631149292,11.343041518345 44.4938875871233 11.2417631149292,11.3428507126776 44.4936954440913 7.48024463653564))),TIN Z (((11.3431277794306 44.4936897573368 5.29770469665527,11.3428507126776 44.4936954440913 7.48024463653564,11.3428507126776 44.4936954440913 5.29770469665527,11.3431277794306 44.4936897573368 5.29770469665527))),TIN Z (((11.3431277794306 44.4936897573368 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527,11.3431277794306 44.4936897573368 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.3431277794306 44.4936897573368 5.29770469665527,11.3430336701609 44.4936916889913 11.2417631149292,11.3428507126776 44.4936954440913 7.48024463653564))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431277794306 44.4936897573368 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431277794306 44.4936897573368 5.29770469665527,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431344482769 44.4938562115227 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3428608533427 44.4939485841042 7.48024463653564,11.3428608533427 44.4939485841042 0,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.3428507126776 44.4936954440913 5.29770469665527,11.3428507126776 44.4936954440913 7.48024463653564,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3428507126776 44.4936954440913 5.29770469665527,11.3428608533427 44.4939485841042 7.48024463653564,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3428507126776 44.4936954440913 5.29770469665527,11.3428548793996 44.4937994577993 0,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3428507126776 44.4936954440913 5.29770469665527))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428608533427 44.4939485841042 0,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.343041518345 44.4938875871233 11.2417631149292,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.343041518345 44.4938875871233 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428548793996 44.4937994577993 0,11.3428608533427 44.4939485841042 0,11.3431344482769 44.4938562115227 2.75583836985302e-16))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3430336701609 44.4936916889913 11.2417631149292,11.3431277794306 44.4936897573368 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.343041518345 44.4938875871233 11.2417631149292,11.3428608533427 44.4939485841042 7.48024463653564,11.342850712677644.4936954440913 7.48024463653564))),TIN Z (((11.3428507126776 44.4936954440913 5.29770469665527,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431277794306 44.4936897573368 5.29770469665527,11.3428507126776 44.4936954440913 5.29770469665527))))

Unfortunately, being a GEOMETRYCOLLECTION, this is also a Shape type that is not supported by MapWinGIS. Perhaps the next step would be to figure out how to unpack the points from this, and import them into a TIN class. The MapWinGIS library has a TIN class that has a method called CreateTinFromPoints. If that works, the TIN could theoretically be loaded by MapWinGIS.

Jerry.