Other ways of opening kml


#1

How do we load a KML file using a web request, byte array, or stream?

Should also note that we are having issues with file locks. We have a scenario where multiple users will hit the code that we are writing, and a file lock causes a lot of problems


#2

@itapplicationsteam,

Thank you for contacting Aspose Support.

We will log a new feature request in our issue tracking system to load KML directly by using web request, byte array, and stream. As a workaround, you may save web request, byte array, and stream to KML file and pass that file to Drivers.Kml.OpenLayer().

Regarding the lock file issue, please share the sample code snippet that causes the lock file issue so that we can investigate it further.


#3

when using this test with a kml we get a object reference not set to an instance of an object

    public void DoTest()
    {

        int x = 1000;

        // Start x threads
        for (int i = 0; i < x; i++)
        {
            System.Threading.Thread thrd = new System.Threading.Thread(new System.Threading.ThreadStart(TestLock));
            thrd.Start();
        }

    }

    public void TestLock()
    {
        Aspose.Gis.Geometries.Point point = new Aspose.Gis.Geometries.Point(-110.3270376, 41.2728755, 0);

        using (var layer = Aspose.Gis.Drivers.Kml.OpenLayer(@"test.kml"))
        {
            // For each layer
            for (int i = 0; i < layer.Count; i++)
            {
                Feature f = layer[i];

                // Check if within geometry
                if (point.Within(f.Geometry))
                {
                    Console.WriteLine("Point is within a geometry is: " + f.GetValue<string>("name"));
                }
            }
        }
    }

however if we do this with a geojson we converted from that xml we have no issue

    public void DoTest()
    {

        int x = 1000;

        // Start x threads
        for (int i = 0; i < x; i++)
        {
            System.Threading.Thread thrd = new System.Threading.Thread(new System.Threading.ThreadStart(TestLock));
            thrd.Start();
        }

    }

    public void TestLock()
    {
        Aspose.Gis.Geometries.Point point = new Aspose.Gis.Geometries.Point(-110.3270376, 41.2728755, 0);

        using (var layer = Aspose.Gis.Drivers.GeoJson.OpenLayer(@"test.GeoJson"))
        {
            // For each layer
            for (int i = 0; i < layer.Count; i++)
            {
                Feature f = layer[i];

                // Check if within geometry
                if (point.Within(f.Geometry))
                {
                    Console.WriteLine("Point is within a geometry is: " + f.GetValue<string>("name"));
                }
            }
        }
    }

#4

@itapplicationsteam,

We were able to reproduce the issue reported by you. We have logged a ticket in our issue tracking system as GISNET-247 to investigate it further. We will update you here as soon as additional information is available.


#5

@itapplicationsteam,

The issue filed as GISNET-247 has been fixed with the release of Aspose.GIS for .NET 18.11.1. Please use the latest version of the API and in case of any further assistance, please feel free to let us know.