[osmosis-dev] Cannot represent -1 as a char.

Brett Henderson brett at bretth.com
Wed Mar 23 09:19:08 GMT 2011


Hi Scott,

I've just modified the serialisation code to serialise the full 32-bit
signed int instead of casting to an unsigned chararacter.

This means that the internal serialisation format will be slightly less
efficient but I suspect the difference will be immeasurable.  Note that
recently I updated the primary id to be stored as a 64-bit signed long
instead of casting to a 32-bit signed int because some users of Osmosis were
expected to run into the limit soon.  That change has an even bigger impact
to the serialised format (4 extra bytes versus 2) so this one isn't worth
worrying about.

Changing your code to 0 would have also worked, but at least this way
there'll be no surprises for anybody else in the future who wishes to use
negative ids.

Cheers,
Brett

On Wed, Mar 9, 2011 at 3:39 PM, Scott Crosby <scott at sacrosby.com> wrote:

> Brett, do you have any advice?
>
> In OsmosisBinaryParser, I'm using NOCHANGESET and NOVERSION when
> there's omitted metadata. Currently both are -1. The bug is because
> another serializer in osmosis is complaining that the version number
> is negative. We can set NOVERSION to 0, make that code more robust, or
> something else.
>
> Scott
>
>
> On Mon, Mar 7, 2011 at 8:01 AM, Nakor <nakor.osm at gmail.com> wrote:
> >
> >> Can you give me more of the stack trace?
> >>
> >> Scott
> >
> > Here you go:
> >
> > SEVERE: Thread for task 1-read-pbf failed
> > org.openstreetmap.osmosis.core.OsmosisRuntimeException: Cannot represent
> -1
> > as a char.
> >    at
> >
> org.openstreetmap.osmosis.core.util.IntAsChar.intToChar(IntAsChar.java:35)
> >    at
> >
> org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData.store(CommonEntityData.java:186)
> >    at
> > org.openstreetmap.osmosis.core.domain.v0_6.Entity.store(Entity.java:138)
> >    at
> org.openstreetmap.osmosis.core.domain.v0_6.Node.store(Node.java:184)
> >    at
> >
> org.openstreetmap.osmosis.core.container.v0_6.NodeContainer.store(NodeContainer.java:49)
> >    at
> >
> org.openstreetmap.osmosis.core.store.BaseObjectWriter.writeObject(BaseObjectWriter.java:63)
> >    at
> >
> org.openstreetmap.osmosis.core.store.SimpleObjectStore.add(SimpleObjectStore.java:106)
> >    at
> >
> org.openstreetmap.osmosis.tagfilter.v0_6.UsedNodeFilter.process(UsedNodeFilter.java:78)
> >    at
> >
> org.openstreetmap.osmosis.core.container.v0_6.NodeContainer.process(NodeContainer.java:58)
> >    at
> >
> org.openstreetmap.osmosis.tagfilter.v0_6.UsedNodeFilter.process(UsedNodeFilter.java:61)
> >    at
> >
> org.openstreetmap.osmosis.tagfilter.v0_6.WayKeyValueFilter.process(WayKeyValueFilter.java:70)
> >    at
> >
> org.openstreetmap.osmosis.core.container.v0_6.NodeContainer.process(NodeContainer.java:58)
> >    at
> >
> org.openstreetmap.osmosis.tagfilter.v0_6.WayKeyValueFilter.process(WayKeyValueFilter.java:53)
> >    at
> >
> crosby.binary.osmosis.OsmosisBinaryParser.parseDense(OsmosisBinaryParser.java:136)
> >    at crosby.binary.BinaryParser.parse(BinaryParser.java:107)
> >    at crosby.binary.BinaryParser.handleBlock(BinaryParser.java:51)
> >    at crosby.binary.file.FileBlock.process(FileBlock.java:117)
> >    at
> crosby.binary.file.BlockInputStream.process(BlockInputStream.java:15)
> >    at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:36)
> >    at java.lang.Thread.run(Unknown Source)
> > Mar 7, 2011 9:01:05 AM org.openstreetmap.osmosis.core.Osmosis main
> > SEVERE: Execution aborted.
> > org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks
> > failed.
> >    at
> >
> org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146)
> >    at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
> >    at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
> >    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >    at java.lang.reflect.Method.invoke(Unknown Source)
> >    at
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
> >    at
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
> >    at
> >
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
> >    at
> > org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> >    at org.codehaus.classworlds.Launcher.main(Launcher.java:31)
> >
> >
>
> _______________________________________________
> osmosis-dev mailing list
> osmosis-dev at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/osmosis-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osmosis-dev/attachments/20110323/e7ffa479/attachment.html>


More information about the osmosis-dev mailing list