0

Some of the geometry fields that are returned from my PostGIS queries are truncated. When I first found this error any geometry fields with more than a few thousand characters would not show up in the pgAdmin Output Pane. So I changed the pgAdmin >> Options >> Query Editor >> Max Characters per column to 32,500 and now the geometry field shows up but it is truncated and ends with "(...)" like the following example;

MULTIPOLYGON(((
    -79.4660582160837 42.211909028322,
    <<..coordinates>>..
    -79.4673861587629 42.212436007559,
    -79.4673871980406 42.212436150477 
   (...)

Any query that ends with the "(...)" fails when I attempt to serialize the result. This occurs on any geometries that have more than a couple thousand characters in them.

I'm pretty sure the issue has something to do with these large geometries because I can successfully run geometries that have fewer vertexes.

When I first found this bug I thought it might be restricted to PostgreSQL 9.2 so I installed version 9.3 and have found the same issue. I also reindexed my table and as far as I can tell the table is not corrupt.

I am also using PostGIS 2.2 bundle for PostgreSQL x64 9.3.

  • How are you performing the serialisation? – John Powell Feb 26 '16 at 6:00
  • 1
    What are you trying to do with the data? Why is this a problem? Are you trying to copy / paste from the output pane? – mlinth Feb 26 '16 at 9:28
1

I was able to solve the issue. It appears that in .NET there is a limit to how long a string that is serialized can be and you must explicitly declare a maxJsonLength in your Web.config. I was able to solve the problem by adding the following to my Web.config:

 <system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="50000000"/>
            </webServices>
        </scripting>
    </system.web.extensions>

This did not change how the result appeared in the pgAdmin output pane but now I can serialize my PostgreSql result set and pass it back to my web application.

  • Might be worth editing your question to make clear that the truncation was happening from a .NET call and was nothing to do with postgres... – mlinth Feb 26 '16 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.