Martin, I've attached a patch for WKBReader that uses the initial endian
flag for multigeometries and ignores the flag for contained geometries if
the endianness flag is something besides the XDR/NDR flags. The patch also
includes a test case that use multigeometries exported from the Spatialite
internal BLOB format.
The patch was made against a recent checkout of JTS 1.14 from the
Sourceforge SVN. Can you apply to the JTS trunk? Let me know if you'd
like me to submit it in some other way.
Thanks........... lreeder
On Mon, Dec 2, 2013 at 4:12 PM, Martin Davis <mtncl...@gmail.com> wrote:
> That strategy still makes sense to me.
>
> M
>
>
> On Mon, Dec 2, 2013 at 2:51 PM, Larry Reeder <lnree...@gmail.com> wrote:
>
>> Now that cold is here, I've got more time to stay indoors and code. I'm
>> willing to submit a JTS patch with sample data and unit tests.
>>
>> Martin, in implementing the patch, I will be following the guidance in
>> your suggestion on April 21, 2013:
>>
>> " The WKBReader can be changed to only switch endianess when
>> the code is one of the two specified in the standard (0 = BigEndian, 1 =
>> LittleEndian). If any other code is read then the endianess will be left
>> unchanged. That should handle the SpatialLite BLOB format, right? And
>> it avoids any explicit dependency on magic numbers from SpatialLite.
>> And it still allows switching endianness mid-WKB, as per the standard,
>> should anyone be so perverse as to do that."
>>
>> Let me know if you see any problems there.
>>
>> Thanks........... lreeder
>>
>>
>> On Mon, Dec 2, 2013 at 3:39 PM, Martin Davis <mtncl...@gmail.com> wrote:
>>
>>> I have very little time to look at this by year-end, I'm afraid.
>>>
>>> Did someone have code to commit for fixing this? (with sample data for
>>> unit tests) ?
>>>
>>>
>>>
>>>
>>> On Mon, Dec 2, 2013 at 1:30 PM, <edgar.sol...@web.de> wrote:
>>>
>>>> On 02.12.2013 22:11, Rahkonen Jukka wrote:
>>>> > Hi,
>>>> >
>>>> > We have many exciting new features and I suppose we will have a great
>>>> new OpenJUMP 1.7 rather soon. It would be excellent to have a well working
>>>> Spatialite support in OJ 1.7 Plus through DB Query plugin, but the issue
>>>> with reading multigeometries remains [1]. Martin almost promised to make a
>>>> fix into JTS [2] but I do not see such a commit in the JTS code [3]. The
>>>> best I can hope to happen is to get the fix into the new BSD/EPL licensed
>>>> JTS release [4] but perhaps Martin is busy with other things and that will
>>>> not happen.
>>>> >
>>>> > Do we have other alternatives for making the DB Query plugin to work
>>>> well with Spatialite on current OJ than flipping in the old JTS version
>>>> when Spatialite support is on a wishlist? Taking an old jts-1.12.jar and
>>>> renaming it into jts-1.13.jar makes the plugin happy but probably breaks
>>>> some cool new stuff and is thus a poor workaround.
>>>> >
>>>> > [1] http://sourceforge.net/p/jts-topo-suite/bugs/36/
>>>> > [2] http://sourceforge.net/p/jts-topo-suite/mailman/message/31118630/
>>>> > [3] http://sourceforge.net/p/jts-topo-suite/code/commit_browser
>>>> > [4] http://sourceforge.net/p/jts-topo-suite/mailman/message/31422827/
>>>> >
>>>>
>>>> i already proposed an alternative,
>>>> http://comments.gmane.org/gmane.comp.java.jts.topo-suite.user/6
>>>>
>>>> but Larry wanted to wait for Martin..
>>>> @Larry, Martin: what's your take on this nearing the end of this year?
>>>>
>>>> ..ede
>>>>
>>>
>>>
>>
>
Index: jts/java/test/com/vividsolutions/jts/io/WKBReaderTest.java
===================================================================
--- jts/java/test/com/vividsolutions/jts/io/WKBReaderTest.java (revision 892)
+++ jts/java/test/com/vividsolutions/jts/io/WKBReaderTest.java (working copy)
@@ -37,6 +37,36 @@
checkWKBGeometry("00000000020000000140590000000000004069000000000000", "LINESTRING (100 200, 100 200)");
}
+ /**
+ * After removing the 39 bytes of MBR info at the front, and the
+ * end-of-geometry byte, * Spatialite native BLOB is very similar
+ * to WKB, except instead of a endian marker at the start of each
+ * geometry in a multi-geometry, it has a start marker of 0x69.
+ * Endianness is determined by the endian value of the multigeometry.
+ *
+ * @throws ParseException
+ */
+ public void testSpatialiteMultiGeometry() throws ParseException
+ {
+ //multipolygon
+ checkWKBGeometry("01060000000200000069030000000100000004000000000000000000444000000000000044400000000000003440000000000080464000000000008046400000000000003E4000000000000044400000000000004440690300000001000000040000000000000000003E40000000000000344000000000000034400000000000002E40000000000000344000000000000039400000000000003E400000000000003440",
+ "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((30 20, 20 15, 20 25, 30 20)))'");
+
+ //multipoint
+ checkWKBGeometry("0104000000020000006901000000000000000000F03F000000000000F03F690100000000000000000000400000000000000040",
+ "MULTIPOINT(1 1,2 2)'");
+
+ //multiline
+ checkWKBGeometry("010500000002000000690200000003000000000000000000244000000000000024400000000000003440000000000000344000000000000024400000000000004440690200000004000000000000000000444000000000000044400000000000003E400000000000003E40000000000000444000000000000034400000000000003E400000000000002440",
+ "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))");
+
+ //geometrycollection
+ checkWKBGeometry(
+ "010700000002000000690100000000000000000010400000000000001840690200000002000000000000000000104000000000000018400000000000001C400000000000002440",
+ "GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))"
+ );
+ }
+
/**
* Not yet implemented satisfactorily.
*
Index: jts/java/src/com/vividsolutions/jts/io/WKBReader.java
===================================================================
--- jts/java/src/com/vividsolutions/jts/io/WKBReader.java (revision 892)
+++ jts/java/src/com/vividsolutions/jts/io/WKBReader.java (working copy)
@@ -156,12 +156,29 @@
private Geometry readGeometry()
throws IOException, ParseException
{
- // determine byte order
- byte byteOrderWKB = dis.readByte();
- // always set byte order, since it may change from geometry to geometry
- int byteOrder = byteOrderWKB == WKBConstants.wkbNDR ? ByteOrderValues.LITTLE_ENDIAN : ByteOrderValues.BIG_ENDIAN;
- dis.setOrder(byteOrder);
-
+
+ // determine byte order
+ byte byteOrderWKB = dis.readByte();
+
+ // always set byte order, since it may change from geometry to geometry
+ if(byteOrderWKB == WKBConstants.wkbNDR)
+ {
+ dis.setOrder(ByteOrderValues.LITTLE_ENDIAN);
+ }
+ else if(byteOrderWKB == WKBConstants.wkbXDR)
+ {
+ dis.setOrder(ByteOrderValues.BIG_ENDIAN);
+ }
+ else if(isStrict)
+ {
+ throw new ParseException("Unknown geometry byte order (not NDR or XDR): " + byteOrderWKB);
+ }
+ //if not strict and not XDR or NDR, then we just use the dis default set at the
+ //start of the geometry (if a multi-geometry). This allows WBKReader to work
+ //with Spatialite native BLOB WKB, as well as other WKB variants that might just
+ //specify endian-ness at the start of the multigeometry.
+
+
int typeInt = dis.readInt();
int geometryType = typeInt & 0xff;
// determine if Z values are present
@@ -286,6 +303,7 @@
{
int numGeom = dis.readInt();
Polygon[] geoms = new Polygon[numGeom];
+
for (int i = 0; i < numGeom; i++) {
Geometry g = readGeometry();
if (! (g instanceof Polygon))
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel