Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Spatial query returns a few rows and then returns an error.

$
0
0

I've been able to reproduce this with a very simple example with various different errors, but can only reproduce this from .NET ADO Provider.

 

This one works fine:

 

SELECT T1.SHAPE.ST_AsBinary() FROM (SELECT * FROM SYSTEM.AUTOBAAN WHERE SHAPE.ST_IntersectsFilter(ST_GeomFromWKT('Polygon((90000 460000, 90000 490000, 160000 490000, 160000 460000, 90000 460000))', 28992)) = 1) T1

 

612 msec

88 records

 

This one fails:

 

SELECT * FROM SYSTEM.AUTOBAAN WHERE SHAPE.ST_IntersectsFilter(ST_GeomFromWKT('Polygon((90000 460000, 90000 490000, 160000 490000, 160000 460000, 90000 460000))', 28992)) = 1

 

Error: Parameter (10) contains null pointer

   at Sap.Data.Hana.HanaCommand._ExecuteReader(CommandBehavior commandBehavior, Boolean isExecuteScalar, Boolean isBeginExecuteReader)

   at Sap.Data.Hana.HanaCommand.ExecuteReaderBatch(CommandBehavior behavior)

   at Sap.Data.Hana.HanaCommand.ExecuteReader()

 

 

 

Another error using WKB.

Notice it fails after retrieving 32 rows...

 

Command: SELECT T1.SHAPE.ST_AsBinary() FROM (SELECT * FROM SYSTEM.AUTOBAAN WHERE SHAPE.ST_IntersectsFilter(ST_GeomFromWKB(:param1, 28992)) = 1) T1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Error: spatial error: exception 1600401: Invalid WKB byte order (28) at position 0

at function st_geomfromwkb()

   at Sap.Data.Hana.HanaException.CheckException(Int32 idEx)

   at Sap.Data.Hana.HanaDataReader.Read()

 

 

Sample code:

 

 

int count = 0;

using (var command = conn.CreateCommand())

{

  int xmin = 90000;

  int ymin = 460000;

  int xmax = 160000;

  int ymax = 490000;

 

  var stream = newMemoryStream();

  var writer = newBinaryWriter(stream);

  writer.Write((byte)1);    // Little Endian

  writer.Write(3);          // WkbPolygon type

  writer.Write(1);          // 1 Ring

 

  writer.Write(5);          // 5 Coordinates

 

  writer.Write((double)xmin);       // X coordinate

  writer.Write((double)ymin);       // Y coordinate

 

  writer.Write((double)xmin);       // X coordinate

  writer.Write((double)ymax);       // Y coordinate

 

  writer.Write((double)xmax);       // X coordinate

  writer.Write((double)ymax);       // Y coordinate

 

  writer.Write((double)xmax);       // X coordinate

  writer.Write((double)ymin);       // Y coordinate

 

  writer.Write((double)xmin);       // X coordinate

  writer.Write((double)ymin);       // Y coordinate

  writer.Flush();

 

  var data = stream.ToArray();

  command.CommandText = $"SELECT T1.SHAPE.ST_AsBinary() FROM (SELECT * FROM SYSTEM.AUTOBAAN WHERE SHAPE.ST_IntersectsFilter(ST_GeomFromWKB(:param1, 28992)) = 1) T1";

  command.CommandType = System.Data.CommandType.Text;

  command.Parameters.Add(newHanaParameter(":param1", data));

 

  Console.WriteLine("Command: {0}", command.CommandText);

  using (var reader = command.ExecuteReader())

  {

    while (reader.Read())

    {

        count++:

        Console.Write("{0} ", count);

 

..

..


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>