mkgmap-r1067/0000755000076400007640000000000011216306457012162 5ustar stevestevemkgmap-r1067/ChangeLog0000644000076400007640000056641411123416553013750 0ustar stevesteve2008-12-20 steve * src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java: Ensure that it is impossible for subdivisions to be too big. They are just limited to the max size if found to be so. 2008-12-16 steve * src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java: Fix the rounding of the map definition areas (I hope). 2008-12-15 steve * src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java, test/uk/me/parabola/mkgmap/osmstyle/StyledConverterTest.java: Points were not copied when overlays were in use. 2008-12-14 steve * mkgmap.ipr, src/uk/me/parabola/mkgmap/combiners/OverviewMap.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMap.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Misc: Rearranged overview map classes. Planning to re-work so that it works again. 2008-12-13 steve * Makefile, mkgmap.ipr, src/uk/me/parabola/imgfmt/ExitException.java, src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/ExitException.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/general/AreaClipper.java, src/uk/me/parabola/mkgmap/general/Clipper.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/LineAdder.java, src/uk/me/parabola/mkgmap/general/NullClipper.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/osmstyle/LineAdder.java, src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java, src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5MapDataSource.java: Misc: Reorganise the package structure to remove cycles that were introduced in the style system. * src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java, test/resources/teststyles/derived, test/resources/teststyles/derived/info, test/resources/teststyles/derived/lines, test/resources/teststyles/derived/version, test/resources/teststyles/simple/lines, test/uk/me/parabola/imgfmt/app/typ/TYPFileTest.java, test/uk/me/parabola/mkgmap/osmstyle/ActionReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/StyledConverterTest.java: Recognise the match operator, add test for derived styles. * src/uk/me/parabola/mkgmap/osmstyle/eval/Op.java, src/uk/me/parabola/mkgmap/osmstyle/eval/RegexOp.java: Add regex operation for rules files. 2008-12-10 steve * resources/styles/noname/lines: The noname style was mostly invisible when in the night-time scheme. So use a different code for named roads. * src/uk/me/parabola/imgfmt/app/trergn/Point.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/general/AreaClipper.java, src/uk/me/parabola/mkgmap/general/Clipper.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/general/NullClipper.java, src/uk/me/parabola/mkgmap/osmstyle/LineAdder.java, src/uk/me/parabola/mkgmap/osmstyle/OverlayReader.java, src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/Tags.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, test/resources/teststyles/simple/lines, test/resources/teststyles/simple/overlays, test/uk/me/parabola/mkgmap/osmstyle/ActionReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/StyledConverterTest.java, test/uk/me/parabola/mkgmap/reader/osm/ElementTest.java, test/uk/me/parabola/mkgmap/reader/osm/TagsTest.java: Implement overlays. With this feature you can have a line style that is formed by over laying two lines. By using a TYP file with appropriate definitions, you can create some useful effects. To use this create an overlays file in the style. Lines in the file look like this: 0x142: 0x12, 0x17, 0x18 This means that if you have a line of type 0x142, it will be written as three lines with types 0x12, 0x17 and 0x18 respectively instead of 0x142. 2008-12-09 steve * mkgmap.iml, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/SimpleMap.java, src/uk/me/parabola/mkgmap/reader/osm/Tags.java, test/uk/me/parabola/mkgmap/reader/osm/TagsTest.java: Rename SimpleMap to Tags to reflect its only use. * src/uk/me/parabola/mkgmap/general/MapElement.java: Bug fix for max resolution. 2008-12-08 steve * Makefile, resources/styles/default/lines, resources/styles/default/relations, resources/styles/noname, resources/styles/noname/info, resources/styles/noname/lines, resources/styles/noname/version, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java, src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StylePrinter.java, src/uk/me/parabola/mkgmap/osmstyle/eval/NotExistsOp.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/SimpleMap.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5MapDataSource.java, test/resources/teststyles/simple/lines, test/uk/me/parabola/mkgmap/osmstyle/ActionReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/StyledConverterTest.java: Add a noname style. Can be used with --style=noname Major roads that do not have a ref, as well as residential roads that do not have a name are highlighted. You can use the tag noname=yes to show that a road doesn't have and name and therefore shouldn't be highlighted. No-name roads show up as a thick line that is visible at higher zooms than is usual for residential roads to help you find areas with poor naming coverage. 2008-12-07 steve * resources/styles/default/info, resources/styles/default/lines, resources/styles/default/map-features.csv, resources/styles/default/points, resources/styles/default/polygons, src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java, src/uk/me/parabola/mkgmap/osmstyle/StylePrinter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/AddTagAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/NameAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, test/resources/teststyles/empty, test/resources/teststyles/empty/points, test/resources/teststyles/empty/relations, test/resources/teststyles/empty/version, test/uk/me/parabola/mkgmap/osmstyle/StyleImplTest.java: Make the default style a rules-based one. Fix a bug when a file is empty. add to strings to the value action rules. * src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ConvertFilter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java, test/uk/me/parabola/mkgmap/osmstyle/actions/AddTagActionTest.java: Remove old hardcoded rules for name and contours but add equivilent rules if you are using an old map-features.csv based style for backward compatibility. New styles have to be particular about how to format the name of a road and how to deal with contour lines etc. * ., doc/style-rules.txt, mkgmap.iml, mkgmap.ipr, src/uk/me/parabola/imgfmt/app/typ, src/uk/me/parabola/mkgmap/Options.java, src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java, src/uk/me/parabola/mkgmap/osmstyle/actions/Action.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ActionReader.java, src/uk/me/parabola/mkgmap/osmstyle/actions/AddTagAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ConvertFilter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/DefaultFilter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/DeleteAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/NameAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/SubAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueFilter.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java, src/uk/me/parabola/mkgmap/osmstyle/eval/Op.java, src/uk/me/parabola/mkgmap/osmstyle/eval/UnitConversions.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Relation.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, test/resources, test/resources/teststyles, test/resources/teststyles/simple, test/resources/teststyles/simple/info, test/resources/teststyles/simple/lines, test/resources/teststyles/simple/options, test/resources/teststyles/simple/version, test/uk, test/uk/me, test/uk/me/parabola, test/uk/me/parabola/mkgmap, test/uk/me/parabola/mkgmap/osmstyle/ActionReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/StyleImplTest.java, test/uk/me/parabola/mkgmap/osmstyle/StyledConverterTest.java, test/uk/me/parabola/mkgmap/osmstyle/actions/AddTagActionTest.java, test/uk/me/parabola/mkgmap/reader, test/uk/me/parabola/mkgmap/reader/osm, test/uk/me/parabola/mkgmap/reader/osm/ElementTest.java: Merge style branch into trunk. The style system is now nearly complete. Will then remove the hardcoded rules for name and contours. * build.xml: Don't include the source in the distributions as we have a separate source one now and have done for a while. 2008-12-06 steve * src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java: Make the MPS file name distinctive. * mkgmap.ipr, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java: Calculate the block size needed for the gmapsupp correctly. Was ignoring the main constraint while concentrating on a minor one.... Also there should be a warning now if the directory overflows. If it does that would be a bug. 2008-12-01 steve * mkgmap.ipr, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java, src/uk/me/parabola/imgfmt/app/typ/BitmapImage.java, src/uk/me/parabola/imgfmt/app/typ/PointInfo.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java, src/uk/me/parabola/mkgmap/general/LineClipper.java, src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, test/uk/me/parabola/imgfmt/app/typ, test/uk/me/parabola/imgfmt/app/typ/TYPFileTest.java: Misc: code clean up. 2008-11-30 steve * src/uk/me/parabola/imgfmt/FormatException.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Writeable.java, src/uk/me/parabola/imgfmt/app/typ, src/uk/me/parabola/imgfmt/app/typ/BitmapImage.java, src/uk/me/parabola/imgfmt/app/typ/DrawOrder.java, src/uk/me/parabola/imgfmt/app/typ/PointInfo.java, src/uk/me/parabola/imgfmt/app/typ/Rgb.java, src/uk/me/parabola/imgfmt/app/typ/ShapeStacking.java, src/uk/me/parabola/imgfmt/app/typ/TYPFile.java, src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java: Brought in the TYP file implementation from Thomas Lußnig. This is from the typpoi branch, there is still more to be integrated from that branch. * src/uk/me/parabola/mkgmap/osmstyle/Action.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StylePrinter.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java: Misc: Code tidy. * ., Makefile, doc/style.txt, mkgmap.ipr, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/general/Clipper.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/PolygonClipper.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/osmstyle/Action.java, src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java, src/uk/me/parabola/mkgmap/osmstyle/DefaultFeatureNames.java, src/uk/me/parabola/mkgmap/osmstyle/JarFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/MapFeatureReader.java, src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java, src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java, src/uk/me/parabola/mkgmap/osmstyle/StyleFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StylePrinter.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java, src/uk/me/parabola/mkgmap/osmstyle/actions, src/uk/me/parabola/mkgmap/osmstyle/actions/Action.java, src/uk/me/parabola/mkgmap/osmstyle/actions/ActionReader.java, src/uk/me/parabola/mkgmap/osmstyle/actions/AddTagAction.java, src/uk/me/parabola/mkgmap/osmstyle/actions/RenameAction.java, src/uk/me/parabola/mkgmap/osmstyle/eval/EqualsOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/NumericOp.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/GeneralRelation.java, src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Relation.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleInfo.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/scan/Token.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, test/uk, test/uk/me, test/uk/me/parabola, test/uk/me/parabola/mkgmap, test/uk/me/parabola/mkgmap/osmstyle, test/uk/me/parabola/mkgmap/osmstyle/ActionReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/RuleFileReaderTest.java, test/uk/me/parabola/mkgmap/osmstyle/actions, test/uk/me/parabola/mkgmap/osmstyle/actions/AddTagActionTest.java: Merge from style branch. * ., ChangeLog, mkgmap.ipr, src/uk/me/parabola/imgfmt/app/BitReader.java, src/uk/me/parabola/mkgmap/Version.java, test/uk/me/parabola/imgfmt, test/uk/me/parabola/imgfmt/app, test/uk/me/parabola/imgfmt/app/BitReaderTest.java, test/uk/me/parabola/mkgmap/general/LineClipperTest.java: Misc: tests, version and changelog updating. 2008-11-29 steve * src/uk/me/parabola/imgfmt/app/BitReader.java: Merge from nod to allow display to compile with trunk * mkgmap.iml, mkgmap.ipr, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/general/LineClipper.java, test/uk, test/uk/me, test/uk/me/parabola, test/uk/me/parabola/mkgmap, test/uk/me/parabola/mkgmap/general, test/uk/me/parabola/mkgmap/general/LineClipperTest.java: Line clipping was producing zero length lines. 2008-11-28 steve * ., mkgmap.ipr, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileImgChannel.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/general/LineClipper.java, src/uk/me/parabola/mkgmap/gui/Main.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/osmstyle/DefaultFeatureNames.java, src/uk/me/parabola/mkgmap/osmstyle/DirectoryFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/eval/Op.java, src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, src/uk/me/parabola/mkgmap/reader/osm/xml/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Code tidying. 2008-11-27 steve * src/uk/me/parabola/imgfmt/Utils.java: Reversing change to the date routines in this file as I suspect they may be causing the recently observed breakage. I remember from the beginning that things dont work if the year field has certain values. 2008-11-23 steve * ChangeLog, doc/Credits, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java: Fixed NumberFormatException problems on map names that are not integers. 2008-11-16 steve * mkgmap.ipr, mkgmap.iws, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Code clean up. * mkgmap.ipr, mkgmap.iws, src/uk/me/parabola/imgfmt/app/BitReader.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/OffsetWriter.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin2Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Utf8Decoder.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java, src/uk/me/parabola/imgfmt/app/net/RoadIndex.java, src/uk/me/parabola/imgfmt/app/trergn/MapValues.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/scan/Token.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java, src/uk/me/parabola/tdbfmt/RBlock.java: Code clean up. * mkgmap.ipr, mkgmap.iws, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/BitReader.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/trergn/Overview.java, src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/io/StructuredInputStream.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java, src/uk/me/parabola/mkgmap/general/AreaClipper.java, src/uk/me/parabola/mkgmap/main/MapOption.java, src/uk/me/parabola/mkgmap/osmstyle/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/xml/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Code clean up. * mkgmap.iml, mkgmap.ipr, mkgmap.iws: Add intellij files. * src/uk/me/parabola/mkgmap/general/LineClipper.java: Fix clipping bug where a line runs parallel to the side we are clipping against. Also changed many double values to int's as we only work in ints for the coordinates anyway. Changed some terminology to better match the web page description of the algorithm. (Bug reported by beej71) 2008-11-12 steve * ., src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java: Merge change to restore the rule ordering within the file. Rules earlier take priority over rules later. 2008-11-10 steve * ., src/uk/me/parabola/mkgmap/general/AreaClipper.java, src/uk/me/parabola/mkgmap/general/Clipper.java, src/uk/me/parabola/mkgmap/general/NullClipper.java, src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java, src/uk/me/parabola/mkgmap/osmstyle/eval/EqualsOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTOp.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java: Merge in important bug fixes from the style branch. Makes all the examples work. 2008-11-09 steve * ., Makefile, doc/style-examples.txt, doc/style-rules.txt, doc/style.txt, scripts/new_style.py, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin2Encoder.java, src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java, src/uk/me/parabola/imgfmt/app/trergn/Point.java, src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/Option.java, src/uk/me/parabola/mkgmap/OptionProcessor.java, src/uk/me/parabola/mkgmap/Options.java, src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/general/Clipper.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/osmstyle, src/uk/me/parabola/mkgmap/osmstyle/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/DefaultFeatureNames.java, src/uk/me/parabola/mkgmap/osmstyle/DirectoryFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java, src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java, src/uk/me/parabola/mkgmap/osmstyle/JarFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/MapFeatureReader.java, src/uk/me/parabola/mkgmap/osmstyle/RuleFileReader.java, src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java, src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java, src/uk/me/parabola/mkgmap/osmstyle/StyleFileLoader.java, src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java, src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java, src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java, src/uk/me/parabola/mkgmap/osmstyle/eval, src/uk/me/parabola/mkgmap/osmstyle/eval/AndOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/BinaryOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/CloseOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/EqualsOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ExistsOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/GTOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTEOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/LTOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/NotEqualOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/NotExistsOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/NotOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/Op.java, src/uk/me/parabola/mkgmap/osmstyle/eval/OpenOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/OrOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/SyntaxException.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ValueOp.java, src/uk/me/parabola/mkgmap/osmstyle/eval/ValueWithUnit.java, src/uk/me/parabola/mkgmap/osmstyle/package.html, src/uk/me/parabola/mkgmap/reader/osm/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/DirectoryFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/GType.java, src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Rule.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/StyleInfo.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/osm/WordScanner.java, src/uk/me/parabola/mkgmap/reader/osm/package.html, src/uk/me/parabola/mkgmap/reader/osm/xml, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/xml/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/plugin/MapReader.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/scan, src/uk/me/parabola/mkgmap/scan/TokType.java, src/uk/me/parabola/mkgmap/scan/Token.java, src/uk/me/parabola/mkgmap/scan/TokenScanner.java: Merge the style branch back to the trunk. Next the branch will be recreated for more work. * src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java, src/uk/me/parabola/mkgmap/Version.java: Change the message when the RGN region overflows. The previous message was confusing, and I don't expect the new one will be any better, but I will keep changing it until it is. Exit the program as there is not point of going on as the map will not work and it is best not to give hope that it will. Bumped the built in version number - thanks Petr for reminding me. 2008-08-31 steve * src/uk/me/parabola/imgfmt/app/BitReader.java: Add a signed get method to the bitreader 2008-08-30 steve * Makefile, src/uk/me/parabola/imgfmt/app/BitReader.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java: Changes to help display rgn files. 2008-08-28 steve * resources/styles/default/map-features.csv: Add highway=path because some people use that. -Markus Barchfeld 2008-08-25 steve * src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: When a reader plugin already contains an empty top level zoom, then we do not want to create a new one so mark such levels specially and use them for creating the empty level instead of creating our own. Thanks to Pazapas for pointing this out. * src/uk/me/parabola/imgfmt/app/Section.java: Apply fix from the nod branch. When sections are linked then the begining of the second should be the end of the previous one (not the start of the previous). Possibly would have caused some weird POI behaviour. 2008-08-24 steve * ChangeLog, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/ImgFileReader.java, src/uk/me/parabola/imgfmt/app/ImgFileWriter.java: Some more changes that should have been included in the previous commit. Two phase writing of the sections. * src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/typ/TYPFile.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java: The sync method was a bad idea for net and nod. We need to separate writing into two phases and control the order that these phases are written in. So: 1. Make sync just write the buffers to the disk. 2. Add write and writePost() methods to control the different phases. Verified that you get the same result file on trunk. 2008-08-22 elrond * src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: Support in .osm The current OSM api sends a . Use it to setup the bounding box. ( is another already supported way.) * resources/map-features.csv, resources/osm_garmin_map.csv, resources/styles/default/map-features.csv: Add new features (archaeological_site, school, playground) point historic=archaeological_site -> attractions|museum-historical polygon amenity=school -> university (closest match) polygon leisure=playground -> city-park (closest match) 2008-08-03 steve * .: Merge tracking for typpoi nod and style branches. 2008-08-02 steve * src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java: Initial fix for polygon smoothing, more to do. - Olaf Kähler * src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: some trivial bugs about converting meters/feet in .mp files... now also all three kinds of contour lines will be processed. - Olaf Kähler 2008-07-28 steve * src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: 1: When using files processed by osmcut some ways which were part of the relation were not in the file causing a null-pointer exception. This is now handled in both OSM5XMLHandler and MultipolygonRelation. 2: I changed the calcutation of the distance between points to also take hemisphere changes into account. The code looks not nice to me however. 3: I uncommented the last line of the insertPoints function as the islands looked ok on my venture HC. It appears only mapsource messes things up. Rene Affourtit 2008-07-27 steve * Makefile, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Completely empty osm files caused mkgmap to go into a loop and run out of memory. Now we just ignore any empty file. If the file still has a valid bounds element then the output will still be produced. Reported by Christian Ehrlicher. 2008-07-23 steve * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: When a way is tagged both riverbank and coastline, then prefer the coastline. This gives the best results until there is code to deal with filling in in-complete polygons. 2008-07-18 steve * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Add the bodge that allows the contour tag have a height specified, to the contour_ext tags too. Requested by a couple of people for use with Srtm2Osm. The mythical new style system will allow this to be configured properly... 2008-07-08 steve * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonRelation.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Relation.java: Patch to add relation support and in particular for the multi polygon relation. known issues: - Areas crossing equator, poles, meridian, dataline will be joined wrong. - connection between inner and outer ways. -Rene_A 2008-07-06 steve * Makefile, src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ReadStrategy.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java: NetDisplay now looks up the number of cities and so can tell if they need one or 2 bytes. * Makefile, src/uk/me/parabola/imgfmt/app/BufferedImgFileReader.java, src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/ImgFileReader.java, src/uk/me/parabola/imgfmt/app/ImgFileWriter.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/OffsetWriter.java, src/uk/me/parabola/imgfmt/app/OffsetWriterList.java, src/uk/me/parabola/imgfmt/app/lbl/City.java, src/uk/me/parabola/imgfmt/app/lbl/Country.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/lbl/Region.java, src/uk/me/parabola/imgfmt/app/lbl/Zip.java, src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java, src/uk/me/parabola/imgfmt/app/net/RoadIndex.java, src/uk/me/parabola/imgfmt/app/trergn/MapObject.java, src/uk/me/parabola/imgfmt/app/trergn/Overview.java, src/uk/me/parabola/imgfmt/app/trergn/Point.java, src/uk/me/parabola/imgfmt/app/trergn/Polyline.java, src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java, src/uk/me/parabola/imgfmt/app/trergn/RGNHeader.java, src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/imgfmt/app/trergn/Zoom.java, src/uk/me/parabola/imgfmt/app/typ/TYPFile.java, src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java: Renamed the ReadStrategy and WriteStrategy interfaces and their associated classes to ImgFileReader and ImgFileWriter etc * src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java: 1. Make overview polygons completely cover the map area. 2. Read family id from tdb header. 3. re-org v4 header writing. 2008-07-05 steve * src/uk/me/parabola/mkgmap/main/Main.java: Fixed --help option. 2008-07-03 steve * src/uk/me/parabola/tdbfmt/TdbFile.java: Removed unneed imports * src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterFilter.java, src/uk/me/parabola/mkgmap/general/LineClipper.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Removed debugging prints, improved display of bounds. * src/uk/me/parabola/tdbfmt/TBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Add the crc to the T block 2008-07-01 steve * Makefile, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/mkgmap/general/LineClipper.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/PolygonClipper.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java: If there is a bounding box in the input file, then use that to clip the output to exactly to that box. 2008-06-29 steve * src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Make the family id default to 0 (due to a bug it, the default was really always 0). Remove v4 block from v3 TDB * resources/help/en/options: Add missing options - Michael Vogt 2008-06-28 steve * src/uk/me/parabola/io/StructuredOutputStream.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/RBlock.java, src/uk/me/parabola/tdbfmt/TBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Adding support for TDB v4. It does not work. 2008-06-23 steve * src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java: The part field appears to be just the one byte. - Johann Gail 2008-06-22 steve * src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Remove System.exit's and unused code. * src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Set family id more consistantly and read the TRE header more completely (whole header is not needed yet, so we just do part of it). 2008-06-21 steve * src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/reader/osm/Segment.java: Segments are long gone. * src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java: Looks like the parent needs to be properly set. (I don't see this crash though) See http://wiki.openstreetmap.org/index.php?title=Talk:Mkgmap&curid=4591&diff=114690&oldid=113277 * Makefile, src/uk/me/parabola/imgfmt/app/OffsetWriter.java, src/uk/me/parabola/imgfmt/app/OffsetWriterList.java, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java, src/uk/me/parabola/imgfmt/app/net/RoadIndex.java, src/uk/me/parabola/imgfmt/app/trergn/Polyline.java, src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/main/MapMaker.java: Merge in the net branch. This gives the ability to add the NET section. The work on the net branch was done by Elrond. 2008-06-20 steve * src/uk/me/parabola/imgfmt/app/trergn/MapValues.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java: Merge in work to extend the TRE header to the 188 byte version. Somewhat experimental at the moment. 2008-05-24 steve * resources/map-features.csv, resources/osm_garmin_map.csv, resources/styles/default/map-features.csv: Added amenity=drinking_water and natural=glacier as suggested by Frédéric Bonifas. 2008-05-15 steve * src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: Protect against bad numeric data in the input file. 2008-05-12 steve * Makefile, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: I believe that the garmin is expecting that the contours are in feet, so we need to convert. You can change how it displays them on the Garmin with an option. 2008-05-03 steve * src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java: Little improvement to NET output routines This allows to create label-only RoadDefs in the NET file. The created NET file looks good using the display tools. 2008-04-28 steve * src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java: Make --map-features a synonym for --style-file like it is meant to be. 2008-04-26 steve * ChangeLog, Makefile, build.xml, doc/Credits, src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java: Tidy up for a release. * src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java: Add StreetNames to POI POIRecords are variable length, have optional flags for the included info and are mostly straight forward. This adds the optional flag writing and one optional field: The StreetName. - Elrond 2008-04-22 steve * src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/trergn/Point.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java: Basic POI support The LBL file contains a section for detailed information about POIs (street, streetnumber, ZIP, phone number). These entries can be linked from the Point-entries in the map subdivisions. For now we only use the Name field in the POIRecord. The user visible change is in MapSource: Most POIs now have a Property context-menu entry, which shows the detailed info. The Point-entry flag was found in qlandkarte. The rest is documented in the imgformat pdf. - Elrond * src/uk/me/parabola/mkgmap/main/Main.java: Add --version option - suggested by Petr Schönmann. Only works properly with packaged versions of mkgmap, not direct from svn. 2008-04-20 steve * ChangeLog, doc/mkgmap.1, resources/help/en/copyright, resources/help/en/help, resources/help/en/inputs, resources/help/en/links, resources/help/en/options: Improvements and additional help files. * resources/styles/default/info, resources/styles/test/info, src/uk/me/parabola/mkgmap/gui/MainFileList.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/reader/osm/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/DirectoryFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/StyleInfo.java, src/uk/me/parabola/mkgmap/reader/osm/WordScanner.java: Can now list styles (not that there are any available yet) Added info file so that a style listing can include information about the style * doc/Credits, doc/mkgmap.1: Add man page, written by Andreas Putzo for the Debian project. 2008-04-19 steve * build.xml, src/uk/me/parabola/mkgmap/gui, src/uk/me/parabola/mkgmap/gui/AppLayout.form, src/uk/me/parabola/mkgmap/gui/AppLayout.java, src/uk/me/parabola/mkgmap/gui/Buttons.form, src/uk/me/parabola/mkgmap/gui/Buttons.java, src/uk/me/parabola/mkgmap/gui/FileModel.java, src/uk/me/parabola/mkgmap/gui/FileOptions.form, src/uk/me/parabola/mkgmap/gui/FileOptions.java, src/uk/me/parabola/mkgmap/gui/FileOptions.properties, src/uk/me/parabola/mkgmap/gui/InputFile.java, src/uk/me/parabola/mkgmap/gui/Main.java, src/uk/me/parabola/mkgmap/gui/Main.properties, src/uk/me/parabola/mkgmap/gui/MainFileList.form, src/uk/me/parabola/mkgmap/gui/MainFileList.java, src/uk/me/parabola/mkgmap/gui/MainFileList.properties, src/uk/me/parabola/mkgmap/gui/MainFileList_en_US.properties, src/uk/me/parabola/mkgmap/gui/MainFileList_no.properties, src/uk/me/parabola/mkgmap/gui/Main_en_US.properties, src/uk/me/parabola/mkgmap/gui/Main_no.properties, src/uk/me/parabola/mkgmap/gui/package.html: gui * resources/help/en/options, resources/styles/default/options, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java: Make the --levels option available inside the style itself. Clean up the help file. 2008-04-13 steve * src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/trergn/Point.java: Start some POIRecord support. Nothing should change in the created maps yet. - Elrond * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Let polygons get predictable garmin types Currently, the order of tags in the input defines the result of the garmin type search for a polygon. Now the type is defined by the order in the map-features.csv. This was done for polylines a while back already. - Elrond * src/uk/me/parabola/mkgmap/reader/osm/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java: Apply overrides to options from the command line. * ChangeLog, Makefile, resources/help/en/help, resources/help/en/options, src/uk/me/parabola/mkgmap/main/Main.java: Add possibility of more help files and the --help option * doc/style.txt, src/uk/me/parabola/imgfmt/FileNotWritableException.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/reader/osm/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/WordScanner.java: Code tidy up. * build.xml, src/uk/me/parabola/mkgmap/main/Main.java: Actually get the option help into the archive and fix typo in message. * build.xml, resources/help, resources/help/en, resources/help/en/options, src/uk/me/parabola/mkgmap/main/Main.java: Add an options help file. * doc/style.txt, resources/styles/default/map-features.csv, src/uk/me/parabola/mkgmap/reader/osm/CombinedStyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/WordScanner.java: In addition to zip file archives, add a simple single file archive type. This also provides backward compatibility with the single map-features.csv file. 2008-04-12 steve * ChangeLog, build.xml, doc/Credits, resources/map-features.csv, resources/styles, resources/styles/default, resources/styles/default/options, resources/styles/default/version, resources/styles/test, resources/styles/test/version, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Add new style directory, tidy up and update. Add Credits file and make build.xml copy it in. * src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/WordScanner.java: Remove Scanner which is not available in GNU classpath. Once openjdk becomes available in all the linux distros, then we can consider using again, but it wasn't doing much good anyway. * src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Remove the usage of Scanner. It ends up looking simpler anyway. 2008-04-10 steve * src/uk/me/parabola/mkgmap/build/MapSplitter.java: Temporary fix for the 'stack-overflow' problem. * src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java, src/uk/me/parabola/imgfmt/app/ReadStrategy.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java: Fix insertion of the copyright strings from the individual files into the TDB file, a bit involved since it never worked after the rewrite of the TDB creation from existing files rather than on the fly. 2008-04-08 steve * resources/osm_garmin_map.csv: More map features from Elrond 2008-04-07 steve * src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Use util routines for string manipulation. Clarify set description routine at the same time. 2008-04-06 steve * src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java: Improve tile names in MapSource: - Let ImgHeader read the Description from the .img - Use that description in writing out the .tdb (Elrond) * src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java: Fix to prevent width or height getting too large * src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java: Add the ability to redifine what is used as the name tag. 2008-03-31 steve * resources/map-features.csv, resources/osm_garmin_map.csv: Add living_street. * src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java: Removed duplicate code and made constructor public again as it is used by the display branch. (Elrond) 2008-03-20 steve * Makefile, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/osm/package.html: More on named styles. 2008-03-15 steve * src/uk/me/parabola/imgfmt/ReadFailedException.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Utf8Encoder.java, src/uk/me/parabola/imgfmt/app/lbl/City.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/Region.java, src/uk/me/parabola/imgfmt/app/lbl/Zip.java, src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java, src/uk/me/parabola/mkgmap/filters/LineSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java: Code tidying. * src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java: Styling development. * resources/map-features.csv, resources/osm_garmin_map.csv: Riverbank is a polygon (strangely). 2008-03-05 steve * src/uk/me/parabola/tdbfmt/EndOfFileException.java, src/uk/me/parabola/tdbfmt/StructuredInputStream.java, src/uk/me/parabola/tdbfmt/StructuredOutputStream.java: Files that should have been removed in the last commit 2008-03-04 steve * src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/mps/MapBlock.java, src/uk/me/parabola/imgfmt/mps/MapsetBlock.java, src/uk/me/parabola/imgfmt/mps/ProductBlock.java, src/uk/me/parabola/io, src/uk/me/parabola/io/EndOfFileException.java, src/uk/me/parabola/io/StructuredInputStream.java, src/uk/me/parabola/io/StructuredOutputStream.java, src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Fix package cycle. * resources/garmin_feature_list.csv, resources/map-features.csv, resources/osm_garmin_map.csv: Patch by Elrond: - Add landuse=scrub and needed garmin feature - Add sport=swimming - Add newer osm names for existing features: shop=supermarket (former: amenity=supermarket) tourism=museum (former: historic=museum) 2008-03-03 steve * Makefile, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java: Fix location of flag and part number in the directory entry. 2008-03-02 steve * src/uk/me/parabola/mkgmap/reader/osm/StyledConverter.java: The new styled converter * src/uk/me/parabola/mkgmap/reader/osm/DirectoryFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/JarFileLoader.java, src/uk/me/parabola/mkgmap/reader/osm/Style.java, src/uk/me/parabola/mkgmap/reader/osm/StyleFileLoader.java: A new styling system to replace the existing single file one. * Makefile, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/labelenc/Utf8Decoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Utf8Encoder.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java: work on character encodings. Preparation for none 8 bit encodings. 2008-02-17 steve * Makefile, src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/OsmXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/Way4.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/plugin/MapReader.java: Removed osm api version 0.4 code. Moved the setting of the element name into the converter, currently the same code, but will allow ofr more sophisticated treatment of names as required for international use and special purpose maps. 2008-02-16 steve * resources/map-features.csv, resources/osm_garmin_map.csv: Applied to wrong branch so merged from bigtre 540,541: --- Patch by Elrond: * Added "ground-transportation" for bus-stops, tram-stops, and railway-halts * bakery is better found under grocery than under xxx4 * Add landuse=village_green --- 2008-02-09 steve * Makefile, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Deal with elevation data on contours that is given in meters. 2008-02-03 steve * Makefile, src/uk/me/parabola/imgfmt/app/trergn/Polyline.java, src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/build/MapArea.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/filters/RemoveEmpty.java, src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java, src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMap.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, test, test/README: Background and sizing fixes. Should fix problem with triangular background areas and areas that don't cover the tile properly. 2008-01-30 steve * src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/main/Main.java: Fix the file merging code when there is more than one FILE_KIND file with the same or no mapname. 2008-01-27 steve * Makefile, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java: Don't copy the MPS file, if there should be one in the input files. * src/uk/me/parabola/imgfmt/mps/MapBlock.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, test: Start to allow configuration of the various parameters in the TDB etc files. 2008-01-26 steve * resources/garmin_feature_list.csv, resources/osm_garmin_map.csv: Just adding allotments and hostels. (Elrond) 2008-01-21 steve * Makefile, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java: Get the format decoder right on reading the LBL file. 2008-01-19 steve * src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Decode the format-6 label format (Robx) * src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java: Factor out writing the section information (patch by Elrond) * Makefile, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapShape.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmXmlHandler.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Add a background polygon to the map. * src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java: Sizing of reserved blocks now works again after allowing for more files. It is still possible for the MPS file to overflow it I guess. * src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java: Wasn't setting the size of the point records correctly, resulting in not all points showing up in find categories. This shows that the garmin devices actually take note of that field - and imgdeocde doesn't. 2008-01-18 steve * src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java: Improve behaviour of read when out of range of the file. * src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java: Calculate the size for the gmapsupp file including all files and not just the basic three. 2008-01-17 steve * src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/labelenc/SimpleDecoder.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java: net and lbl changes * src/uk/me/parabola/mkgmap/CommandArgs.java: Fix the default code page which was always supposed to be 1252 2008-01-14 steve * Makefile, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Look up polygons before lines. Therefore if there is a tagging conflict then the one that specifies an area wins. 2008-01-12 steve * Makefile: Read files from within the img file where possible. 2008-01-08 steve * Makefile, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java, src/uk/me/parabola/mkgmap/build/MapArea.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java: More implementation of the city indexed points. * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Allow more than one map feature to match and take the one that is first in the map-features file. 2008-01-06 steve * src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFactory.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/lbl/City.java, src/uk/me/parabola/imgfmt/app/lbl/Country.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/lbl/Region.java, src/uk/me/parabola/imgfmt/app/lbl/Zip.java, src/uk/me/parabola/imgfmt/app/net, src/uk/me/parabola/imgfmt/app/net/NETFile.java, src/uk/me/parabola/imgfmt/app/net/NETHeader.java, src/uk/me/parabola/imgfmt/app/net/RoadDef.java, src/uk/me/parabola/imgfmt/app/net/RoadIndex.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/mkgmap/Version.java: A lot of initial code for cities and the NET section. 2008-01-03 steve * src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin1Encoder.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/MapMaker.java: Add a --lower-case option it may be useful for the nuvi etc. 2008-01-02 steve * resources/map-features.csv, resources/osm_garmin_map.csv: Patch to add a couple of features. Submitted by Elrond. * ChangeLog, Makefile, src/uk/me/parabola/mkgmap/ArgumentProcessor.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java: Update changelog makefile add javadoc comment, etc 2008-01-01 steve * src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFactory.java, src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java, src/uk/me/parabola/imgfmt/app/labelenc/SimpleDecoder.java, src/uk/me/parabola/imgfmt/app/lbl/City.java, src/uk/me/parabola/imgfmt/app/lbl/Country.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java, src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java, src/uk/me/parabola/imgfmt/app/lbl/Region.java, src/uk/me/parabola/imgfmt/app/lbl/Zip.java: Re-wrote the label section to allow the addition of the city,region,country,zip,poi sections. 2007-12-28 steve * test: MDX file displayer. I don't really know what this does so don't trust this too much. Appears to be another file containing a list of the maps in a set. As the file gets installed at the family level, it could be family wide though. * doc/Zoom, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java: Add a doc file Fix previous merge of label read changes that didn't compile. * test/java: All this has been moved to a separate repo. * src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/labelenc/CharacterDecoder.java, src/uk/me/parabola/imgfmt/app/labelenc/SimpleDecoder.java, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java: Changes for reading the LBL file. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/ShapeStacking.java, src/uk/me/parabola/imgfmt/app/TYPFile.java, src/uk/me/parabola/imgfmt/app/TYPHeader.java: These should have been removed in the last commit. * src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/InternalFiles.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/LBLHeader.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/PointOverview.java, src/uk/me/parabola/imgfmt/app/Polygon.java, src/uk/me/parabola/imgfmt/app/PolygonOverview.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/PolylineOverview.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/RGNHeader.java, src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/TREHeader.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java, src/uk/me/parabola/imgfmt/app/lbl, src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java, src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java, src/uk/me/parabola/imgfmt/app/lbl/package.html, src/uk/me/parabola/imgfmt/app/map, src/uk/me/parabola/imgfmt/app/map/Map.java, src/uk/me/parabola/imgfmt/app/map/package.html, src/uk/me/parabola/imgfmt/app/package.html, src/uk/me/parabola/imgfmt/app/trergn, src/uk/me/parabola/imgfmt/app/trergn/InternalFiles.java, src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java, src/uk/me/parabola/imgfmt/app/trergn/MapObject.java, src/uk/me/parabola/imgfmt/app/trergn/Overview.java, src/uk/me/parabola/imgfmt/app/trergn/Point.java, src/uk/me/parabola/imgfmt/app/trergn/PointOverview.java, src/uk/me/parabola/imgfmt/app/trergn/Polygon.java, src/uk/me/parabola/imgfmt/app/trergn/PolygonOverview.java, src/uk/me/parabola/imgfmt/app/trergn/Polyline.java, src/uk/me/parabola/imgfmt/app/trergn/PolylineOverview.java, src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java, src/uk/me/parabola/imgfmt/app/trergn/RGNHeader.java, src/uk/me/parabola/imgfmt/app/trergn/Subdivision.java, src/uk/me/parabola/imgfmt/app/trergn/TREFile.java, src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java, src/uk/me/parabola/imgfmt/app/trergn/Zoom.java, src/uk/me/parabola/imgfmt/app/trergn/package.html, src/uk/me/parabola/imgfmt/app/typ, src/uk/me/parabola/imgfmt/app/typ/ShapeStacking.java, src/uk/me/parabola/imgfmt/app/typ/TYPFile.java, src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java, src/uk/me/parabola/imgfmt/app/typ/package.html, src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/mps/MpsFile.java, src/uk/me/parabola/mkgmap/build/MapArea.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/general/MapDataSource.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/reader/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, test: Complete re-arrangement of files under the app package as it is already quite large and more files will be added here soon. 2007-12-21 steve * ., src/uk/me/parabola/imgfmt/app/Section.java, src/uk/me/parabola/imgfmt/app/ShapeStacking.java, src/uk/me/parabola/imgfmt/app/TREHeader.java, src/uk/me/parabola/imgfmt/app/TYPFile.java, src/uk/me/parabola/imgfmt/app/TYPHeader.java, src/uk/me/parabola/imgfmt/sys/FileImgChannel.java, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, test/java/test/TypTest.java, test/java/test/display, test/java/test/display/DisplayItem.java, test/java/test/display/Displayer.java, test/java/test/display/LineSectDisplayer.java, test/java/test/display/MpsDisplay.java, test/java/test/display/PointDisplayer.java, test/java/test/display/PolygonDisplayer.java, test/java/test/display/StackingDisplayer.java, test/java/test/display/TypDisplay.java: Merged revisions 474-480,482-485,487,489-505 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/typfile ........ r474 | steve | 2007-12-15 14:07:00 +0000 (Sat, 15 Dec 2007) | 2 lines Print out the header and the fields we think are pointers and sizes. This should lead to finding the other pointers. ........ r475 | steve | 2007-12-15 14:48:46 +0000 (Sat, 15 Dec 2007) | 1 line analyse the sections found, print gaps between them and size fields found and speculated. ........ r476 | steve | 2007-12-15 15:06:16 +0000 (Sat, 15 Dec 2007) | 1 line Appears to be another section, and probably another to be discovered. ........ r477 | steve | 2007-12-15 15:16:54 +0000 (Sat, 15 Dec 2007) | 1 line Better printing of body lines. ........ r478 | steve | 2007-12-15 15:49:51 +0000 (Sat, 15 Dec 2007) | 2 lines Fixed bug that was hiding section sizes. Have probably got sect 5 and 6 lengths now. ........ r479 | steve | 2007-12-15 16:05:10 +0000 (Sat, 15 Dec 2007) | 1 line More possible sizes ........ r480 | steve | 2007-12-15 18:54:40 +0000 (Sat, 15 Dec 2007) | 2 lines Fixed bug not showing gaps between some known values. Looks like the header is decoded fully as far as sections goes as there is not room for any more. ........ r482 | steve | 2007-12-15 20:07:22 +0000 (Sat, 15 Dec 2007) | 2 lines Added sections discovered into the TYP header read/write functions. Verified that what is read is written and can be read again. ........ r483 | steve | 2007-12-15 22:59:55 +0000 (Sat, 15 Dec 2007) | 1 line Most of the unknowns are certainly item sizes like in the TRE file, so add them. ........ r484 | steve | 2007-12-16 15:28:12 +0000 (Sun, 16 Dec 2007) | 1 line TYP file displayer ........ r485 | steve | 2007-12-16 15:53:59 +0000 (Sun, 16 Dec 2007) | 1 line Some name changes. ........ r487 | steve | 2007-12-16 18:12:22 +0000 (Sun, 16 Dec 2007) | 1 line Initial printing of the line sections. still lots is unknown. ........ r493 | steve | 2007-12-16 21:55:09 +0000 (Sun, 16 Dec 2007) | 2 lines Should have been removed in a rename before ........ r494 | steve | 2007-12-16 22:39:01 +0000 (Sun, 16 Dec 2007) | 1 line Add the stacking order section. Fixes and documentation. ........ r495 | steve | 2007-12-18 12:28:20 +0000 (Tue, 18 Dec 2007) | 1 line Print out the mps file. ........ r496 | steve | 2007-12-18 13:55:59 +0000 (Tue, 18 Dec 2007) | 1 line Better printing of line styles ........ r497 | steve | 2007-12-18 16:33:56 +0000 (Tue, 18 Dec 2007) | 1 line Make sense of flags ending with 01 ........ r498 | steve | 2007-12-18 16:34:57 +0000 (Tue, 18 Dec 2007) | 1 line write out a copy of each file. ........ r499 | steve | 2007-12-18 16:35:24 +0000 (Tue, 18 Dec 2007) | 1 line make a horizontal component of lines. ........ r500 | steve | 2007-12-19 09:14:27 +0000 (Wed, 19 Dec 2007) | 2 lines Add classes for points and polygons (these may be the wrong way round). ........ r501 | steve | 2007-12-19 09:15:00 +0000 (Wed, 19 Dec 2007) | 1 line reword in comment ........ 2007-12-20 steve * src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/mps/MapBlock.java, src/uk/me/parabola/imgfmt/mps/MapsetBlock.java, src/uk/me/parabola/imgfmt/mps/MpsFile.java, src/uk/me/parabola/imgfmt/mps/ProductBlock.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/tdbfmt/StructuredOutputStream.java: MPS file working at a first glance. * src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/mps/MapBlock.java, src/uk/me/parabola/imgfmt/mps/MapsetBlock.java, src/uk/me/parabola/imgfmt/mps/MpsFile.java, src/uk/me/parabola/imgfmt/mps/ProductBlock.java, src/uk/me/parabola/tdbfmt/StructuredOutputStream.java: Most of the MPS file implemented. 2007-12-19 steve * test/java/test/CopyFile.java: Re-instate creating real files from the internal files. * src/uk/me/parabola/imgfmt/mps, src/uk/me/parabola/imgfmt/mps/Block.java, src/uk/me/parabola/imgfmt/mps/MapBlock.java, src/uk/me/parabola/imgfmt/mps/MapsetBlock.java, src/uk/me/parabola/imgfmt/mps/MpsFile.java, src/uk/me/parabola/imgfmt/mps/ProductBlock.java, src/uk/me/parabola/imgfmt/mps/package.html: Add MPS file skeleton 2007-12-16 steve * src/uk/me/parabola/mkgmap/CommandArgs.java: Remove redundant initialiser. Forgot to mention in the previous commit that the idea for naming after the input files was requested by Computerteddy. * Makefile, src/uk/me/parabola/mkgmap/CommandArgs.java: If the input file name contains an 8 digit number (in the file name part) then use that as the mapname, unless an explicit name has been specifited. If there are a mixture of files that are numbers and not, then it is always possible that you will get conflicts. * ., src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/sys/FileImgChannel.java: Merged revisions 481,486,488 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/typfile ........ r481 | steve | 2007-12-15 19:58:34 +0000 (Sat, 15 Dec 2007) | 1 line Reading of ints were being cast to char! ........ r486 | steve | 2007-12-16 16:41:10 +0000 (Sun, 16 Dec 2007) | 1 line Fix for the file img channel not really seeking. ........ r488 | steve | 2007-12-16 18:13:08 +0000 (Sun, 16 Dec 2007) | 1 line Make sure there is enough room in the buffer on put3 operations ........ * .: Initialized merge tracking via "svnmerge" with revisions "1-473" from https://svn.parabola.me.uk/svn/mkgmap/branches/typfile 2007-12-15 steve * src/uk/me/parabola/imgfmt/sys/FileImgChannel.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java: Allow more than .img files on the command line when combining. Other file types will be treated as appropriate to the operation being performed. * src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/RGNFile.java: General consistency changes. * ChangeLog, Makefile, src/uk/me/parabola/imgfmt/app/TYPFile.java, src/uk/me/parabola/imgfmt/app/TYPHeader.java, test/java/test/TypTest.java: Test decoding program for the TYP file. 2007-12-14 steve * .: Removed merge tracking for "svnmerge" for https://svn.parabola.me.uk/svn/mkgmap/branches/imgread * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/main/FileInfo.java: These should have been removed as part of the change to remove package cycles. * ., Makefile, src/uk/me/parabola/imgfmt/ReadFailedException.java, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/BufferedReadStrategy.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/CommonHeader.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/LBLHeader.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/RGNHeader.java, src/uk/me/parabola/imgfmt/app/ReadStrategy.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/TREHeader.java, src/uk/me/parabola/imgfmt/app/TYPFile.java, src/uk/me/parabola/imgfmt/app/TYPHeader.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/sys/FileNode.java: Merged revisions 456-465 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/imgread ........ r457 | steve | 2007-12-14 13:43:42 +0000 (Fri, 14 Dec 2007) | 7 lines NON-COMPILING Prepare to factor out the headers from the file definitions. CommonHeader created and the TREHeader that extends from that. ImgFile will not be used for reading and writing directly, but will have reader and writer streams, which will be implemented separately. ........ r458 | steve | 2007-12-14 14:27:32 +0000 (Fri, 14 Dec 2007) | 2 lines Separate out the reader and writer in the ImgFile and add the header there. Compiles, but will not work. ........ r459 | steve | 2007-12-14 15:17:35 +0000 (Fri, 14 Dec 2007) | 1 line Took all the read/write methods off ImgFile and made everything use the reader/writer. ........ r460 | steve | 2007-12-14 15:22:35 +0000 (Fri, 14 Dec 2007) | 1 line The RGN file and header now complete and may work. ........ r461 | steve | 2007-12-14 17:52:03 +0000 (Fri, 14 Dec 2007) | 1 line Bug fixed and working. Verified same results over a set of UK tiles. ........ r462 | steve | 2007-12-14 18:02:42 +0000 (Fri, 14 Dec 2007) | 1 line Code tidy ........ r464 | steve | 2007-12-14 18:32:55 +0000 (Fri, 14 Dec 2007) | 1 line Made the TRE header a bit neater by reducing the number of separate fields. ........ * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/MapReader.java, src/uk/me/parabola/mkgmap/ArgumentProcessor.java, src/uk/me/parabola/mkgmap/CommandArgs.java, src/uk/me/parabola/mkgmap/build/MapArea.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/combiners/Combiner.java, src/uk/me/parabola/mkgmap/combiners/FileInfo.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/ArgumentProcessor.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/main/MapProcessor.java: Move classes around to avoid pakcage cycles. Removed unused class. * src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Removed unused or duplicate methods. * .: Initialized merge tracking via "svnmerge" with revisions "1-455" from https://svn.parabola.me.uk/svn/mkgmap/branches/imgread * .: Removed merge tracking for "svnmerge" for https://svn.parabola.me.uk/svn/mkgmap/branches/gmapsupp https://svn.parabola.me.uk/svn/mkgmap/branches/filter https://svn.parabola.me.uk/svn/mkgmap/branches/lang * ChangeLog: updated changelog 2007-12-12 steve * Makefile, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Fix for not loading in map source. Increase the number in the header to increase the size of the 'file system' * Makefile, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: Moved the line size splitting so that it is nearby the polygon splitting. * Makefile, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/mkgmap/main/FileInfo.java, src/uk/me/parabola/mkgmap/main/Main.java: removed debugging statements * ., Makefile, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/MapReader.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/fs/DirectoryEntry.java, src/uk/me/parabola/imgfmt/fs/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/mkgmap/combiners, src/uk/me/parabola/mkgmap/combiners/Combiner.java, src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/ArgumentProcessor.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/FileInfo.java, src/uk/me/parabola/mkgmap/main/FilenameProcessor.java, src/uk/me/parabola/mkgmap/main/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MapEventListener.java, src/uk/me/parabola/mkgmap/main/MapMaker.java, src/uk/me/parabola/mkgmap/main/MapProcessor.java, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java, src/uk/me/parabola/mkgmap/main/package.html, src/uk/me/parabola/mkgmap/reader/overview/OverviewMap.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Merged revisions 388-447 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/gmapsupp ................ r410 | steve | 2007-12-03 23:02:33 +0000 (Mon, 03 Dec 2007) | 2 lines Progressing with adding .img files to the gmapsupp. Need to create a structure with just file sizes in I think as that is all we actually use. ................ r411 | steve | 2007-12-04 17:31:28 +0000 (Tue, 04 Dec 2007) | 3 lines Before when we couldn't read .img files, there was a need for a complex system to hook all the summarising functions into the main map making process. We don't need to do this any more. We are just going to reprocess the filenames, including any created files. ................ r412 | steve | 2007-12-04 17:34:49 +0000 (Tue, 04 Dec 2007) | 9 lines Merged revisions 404 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/trunk ........ r404 | steve | 2007-12-03 12:11:46 +0000 (Mon, 03 Dec 2007) | 2 lines Change to be compatible with java-5 ........ ................ r413 | steve | 2007-12-04 18:02:01 +0000 (Tue, 04 Dec 2007) | 1 line Get the output filenames from the map making process. ................ r414 | steve | 2007-12-04 18:03:10 +0000 (Tue, 04 Dec 2007) | 9 lines Merged revisions 373 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/trunk ........ r373 | steve | 2007-11-15 00:53:07 +0000 (Thu, 15 Nov 2007) | 1 line Remove call to constructor that is not in 1.5 ........ ................ r415 | steve | 2007-12-04 18:06:57 +0000 (Tue, 04 Dec 2007) | 1 line Move the overview builders into a new package. ................ r416 | steve | 2007-12-04 20:50:06 +0000 (Tue, 04 Dec 2007) | 2 lines Begin on separate reading of img file to combine them. This is going to be a bigger task than I thought as we need to read more of the files than I thought and we should probably introduce file header classes for TRE etc. ................ r418 | steve | 2007-12-05 21:24:26 +0000 (Wed, 05 Dec 2007) | 1 line got the bounds from the TRE section. ................ r419 | steve | 2007-12-05 21:28:39 +0000 (Wed, 05 Dec 2007) | 1 line Add close method. ................ r420 | steve | 2007-12-05 21:29:16 +0000 (Wed, 05 Dec 2007) | 1 line Renamed formal param. ................ r442 | steve | 2007-12-09 23:40:45 +0000 (Sun, 09 Dec 2007) | 1 line Half way working for the gmapsupp case. Looks like there is an off by one in the header dir space calc. ................ r443 | steve | 2007-12-10 22:45:36 +0000 (Mon, 10 Dec 2007) | 1 line Fixed the off by one error, caused by needing to round up. ................ r444 | steve | 2007-12-10 22:53:16 +0000 (Mon, 10 Dec 2007) | 1 line Add the tdb and overview map combiners. ................ r447 | steve | 2007-12-12 14:33:31 +0000 (Wed, 12 Dec 2007) | 1 line Working TDB and overview map generation. ................ * src/uk/me/parabola/mkgmap/Version.java: Get version file from the root directory in the classpath. * Makefile, src/uk/me/parabola/mkgmap/Version.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java: Add version stamping of the resulting maps. 2007-12-09 steve * .: ignored files. * Makefile, src/uk/me/parabola/imgfmt/FileNotWritableException.java, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java, src/uk/me/parabola/mkgmap/filters/MapFilterChain.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterBase.java, src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java: Code tidy up. * src/uk/me/parabola/mkgmap/filters/PolygonSplitterBase.java, src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java: Remove unsed code. * src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapArea.java: Polygon splitting code changes. * src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java: Change to use setResolution on filter config. * src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java: Make getLocation public * src/uk/me/parabola/imgfmt/app/Area.java: Add contains methods * src/uk/me/parabola/mkgmap/main/MakeMap.java: Narrow scope of a couple of variables * Makefile, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/general/MapArea.java: Moved the polygon size filtering code to where a level is initially created. 2007-12-08 steve * src/uk/me/parabola/mkgmap/filters/PolygonSplitterBase.java: Remove name changing code. * Makefile, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterBase.java: Bug in determining the number of bits for the deltas. Showed up in the polygon splitting, but nothing to do with that splitting specifically. 2007-12-07 steve * src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: The polygons were not being split based on the resolution, which meant that the overview map polygons were being split inappropriately. Move split to the correct place. The line splitting should be moved here too. 2007-12-06 steve * src/uk/me/parabola/mkgmap/general/MapDetails.java: Remove println * Makefile, src/uk/me/parabola/mkgmap/filters/PolygonSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterBase.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: Split polygons for size as well as number of points. The splitting is improved too I think. * ChangeLog: Update changelog * Makefile, src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java: Tone down the smoothing a lot as it was way over the top. * ., src/uk/me/parabola/mkgmap/filters/LineSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: Merged revisions 424 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/filters ........ r424 | steve | 2007-12-06 21:09:28 +0000 (Thu, 06 Dec 2007) | 1 line Trivial bug where I was subtracting max-max not max-min ........ 2007-12-05 steve * ., src/uk/me/parabola/mkgmap/filters/LineSizeSplitterFilter.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: Merged revisions 417-422 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/filters ........ r421 | steve | 2007-12-05 23:34:24 +0000 (Wed, 05 Dec 2007) | 1 line Split lines that are too big in the sense of size, rather than too many points. ........ r422 | steve | 2007-12-05 23:35:34 +0000 (Wed, 05 Dec 2007) | 1 line remove debugging ........ 2007-12-04 steve * ., Makefile, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/build, src/uk/me/parabola/mkgmap/build/LayerFilterChain.java, src/uk/me/parabola/mkgmap/build/MapBuilder.java, src/uk/me/parabola/mkgmap/build/MapSplitter.java, src/uk/me/parabola/mkgmap/build/package.html, src/uk/me/parabola/mkgmap/filters, src/uk/me/parabola/mkgmap/filters/BaseFilter.java, src/uk/me/parabola/mkgmap/filters/FilterConfig.java, src/uk/me/parabola/mkgmap/filters/LineSplitterFilter.java, src/uk/me/parabola/mkgmap/filters/MapFilter.java, src/uk/me/parabola/mkgmap/filters/MapFilterChain.java, src/uk/me/parabola/mkgmap/filters/PolygonSplitterFilter.java, src/uk/me/parabola/mkgmap/filters/RemoveEmpty.java, src/uk/me/parabola/mkgmap/filters/SmoothingFilter.java, src/uk/me/parabola/mkgmap/filters/package.html, src/uk/me/parabola/mkgmap/general/MapBuilder.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapShape.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java: Merged revisions 391-416 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/filters ........ r391 | steve | 2007-12-01 17:22:34 +0000 (Sat, 01 Dec 2007) | 1 line Broke out the splitting of lines a little. ........ r392 | steve | 2007-12-01 17:28:23 +0000 (Sat, 01 Dec 2007) | 1 line Remove the inline line splitting code. ........ r393 | steve | 2007-12-01 20:29:03 +0000 (Sat, 01 Dec 2007) | 1 line Create filter infrastructure. ........ r394 | steve | 2007-12-02 14:35:27 +0000 (Sun, 02 Dec 2007) | 2 lines A working implementation, although there is more to break out into filters and then we need to add some more functionality. ........ r395 | steve | 2007-12-02 22:12:43 +0000 (Sun, 02 Dec 2007) | 1 line rename filter chain ........ r396 | steve | 2007-12-02 22:13:25 +0000 (Sun, 02 Dec 2007) | 1 line rename line splitting filter ........ r397 | steve | 2007-12-03 09:00:24 +0000 (Mon, 03 Dec 2007) | 1 line rename line splitting filter, add polygon splitter ........ r398 | steve | 2007-12-03 10:28:16 +0000 (Mon, 03 Dec 2007) | 1 line Make sure that lines are always copied before changing their points as this would change them for all levels. ........ r399 | steve | 2007-12-03 10:29:17 +0000 (Mon, 03 Dec 2007) | 1 line Add the copy constructors to the MapShape class too. ........ r400 | steve | 2007-12-03 11:03:36 +0000 (Mon, 03 Dec 2007) | 1 line Add filtering for polygons and only add the line filter for lines and the polygon filters for polygons... ........ r401 | steve | 2007-12-03 11:22:18 +0000 (Mon, 03 Dec 2007) | 1 line Some tidying ........ r402 | steve | 2007-12-03 12:07:22 +0000 (Mon, 03 Dec 2007) | 1 line Split out files from the general package that do the actual general-->garmin conversion. ........ r405 | steve | 2007-12-03 17:23:48 +0000 (Mon, 03 Dec 2007) | 1 line Useful amount of smothing applied. ........ r406 | steve | 2007-12-03 20:58:29 +0000 (Mon, 03 Dec 2007) | 1 line Fix where was not returning after chaining the filter. ........ r407 | steve | 2007-12-03 20:59:07 +0000 (Mon, 03 Dec 2007) | 1 line Now we have a polygon splitter. Polygons that have too many points will be split. ........ r408 | steve | 2007-12-03 21:16:07 +0000 (Mon, 03 Dec 2007) | 2 lines Remove println's ........ r409 | steve | 2007-12-03 21:23:57 +0000 (Mon, 03 Dec 2007) | 1 line Now that the smoothing is in a filter, remove the old code to remove duplicate points. ........ 2007-12-03 steve * src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java: Change to be compatible with java-5 * .: Initialized merge tracking via "svnmerge" with revisions "1-389" from https://svn.parabola.me.uk/svn/mkgmap/branches/filters 2007-11-24 steve * ., Makefile, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/package.html, src/uk/me/parabola/mkgmap/main/FileInfo.java, src/uk/me/parabola/mkgmap/main/GmapsuppBuilder.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MapEventListener.java, src/uk/me/parabola/mkgmap/main/MapEvents.java, src/uk/me/parabola/mkgmap/main/MapProcessor.java, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Merged revisions 371-377,379-384,386-387 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/gmapsupp ........ r371 | steve | 2007-11-15 00:21:24 +0000 (Thu, 15 Nov 2007) | 2 lines Allow several different listeners to be added to the map making processes. One will be the overview map as before, and we need to keep track of input files for the gmapsupp too. ........ r377 | steve | 2007-11-15 10:06:37 +0000 (Thu, 15 Nov 2007) | 2 lines Part of the rename ........ r379 | steve | 2007-11-15 12:36:38 +0000 (Thu, 15 Nov 2007) | 1 line Its clear how the skeleton of the implementation is going to play out now. ........ r380 | steve | 2007-11-15 15:43:36 +0000 (Thu, 15 Nov 2007) | 3 lines The first working gmapsupp.img file produced. It does not have an overview map or an TDB but that doesn't actually seem to matter and it works find on my garmin device. In fact you are probably not supposed to put the TDB and the overview in there? Is it just for mapsource? ........ r381 | steve | 2007-11-15 16:39:17 +0000 (Thu, 15 Nov 2007) | 3 lines Use linked hash map for predictible ordering of the maps in the output. Break up a deeply nested routine a bit. ........ r383 | steve | 2007-11-17 11:45:06 +0000 (Sat, 17 Nov 2007) | 1 line FIx some problems with the header. ........ r384 | steve | 2007-11-17 14:54:26 +0000 (Sat, 17 Nov 2007) | 2 lines Update to new location of tests. ........ 2007-11-23 steve * ., Makefile, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Merged revisions 385 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/gmapsupp ........ r385 | steve | 2007-11-22 20:59:42 +0000 (Thu, 22 Nov 2007) | 1 line Upper case the strings read in from the translitteration tables. Else if you have Ch for example, then the 'h' does not show up. ........ * .: Initialized merge tracking via "svnmerge" with revisions "1-369" from https://svn.parabola.me.uk/svn/mkgmap/branches/gmapsupp 2007-11-15 steve * build.xml: Copy the doc to the distribution directory. * src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java: Fix calls to PolylineOverview() constructor, note that these files probably don't work any longer anyway. * src/uk/me/parabola/mkgmap/reader/plugin/MapperBasedMapDataSource.java: This should have been removed in the previous commit * src/uk/me/parabola/mkgmap/reader/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java: Get rid of package dependancy cycle * src/uk/me/parabola/imgfmt/FileNotWritableException.java: Remove call to constructor that is not in 1.5 * README: Bring the README file more up to date. 2007-11-14 steve * Makefile, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/mkgmap/general/MapDetails.java: Fix the overview records. * ., build.xml, resources/chars, resources/chars/ascii, resources/chars/ascii/row00.trans, resources/chars/ascii/row01.trans, resources/chars/ascii/row02.trans, resources/chars/ascii/row03.trans, resources/chars/ascii/row04.trans, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/TableCreator.java: Merged revisions 345-350,352-366 via svnmerge from https://svn.parabola.me.uk/svn/mkgmap/branches/lang ........ r345 | steve | 2007-11-02 00:33:22 +0000 (Fri, 02 Nov 2007) | 1 line allow any charset as a target ........ r350 | steve | 2007-11-03 17:45:54 +0000 (Sat, 03 Nov 2007) | 1 line Allow for making upper-casing optional ........ r352 | steve | 2007-11-04 16:49:05 +0000 (Sun, 04 Nov 2007) | 2 lines Make all the transliteration for the acsii-only mode to be table driven. ........ r353 | steve | 2007-11-04 19:03:47 +0000 (Sun, 04 Nov 2007) | 2 lines Added missing (blank) character translit maps. ........ r354 | steve | 2007-11-04 20:00:53 +0000 (Sun, 04 Nov 2007) | 2 lines Build changes needed for character tables. ........ r360 | steve | 2007-11-06 23:02:49 +0000 (Tue, 06 Nov 2007) | 2 lines Russian transliteration provided by User:Liosha ........ 2007-11-13 steve * src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java: Changed default level definitions. * resources/map-features.csv, resources/osm_garmin_map.csv: Improved set of levels for the map features by Jochen Topf. * src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/PointOverview.java, src/uk/me/parabola/imgfmt/app/PolygonOverview.java, src/uk/me/parabola/imgfmt/app/PolylineOverview.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Finally made the overview sections actually reflect the levels at which things appear. Calculate the levels for the overview map, so that they do not overlap with any of the inputs, even if they are set to non-default values. 2007-11-10 steve * Makefile, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Fix the dimentions in the TDB file. Couple of other fixes for the overview map. Also the name of the overview map now does not have the trailing zeros. * src/uk/me/parabola/imgfmt/sys/Dirent.java: If the name is not eight characters then truncate or left pad with zeros. 2007-11-09 steve * src/uk/me/parabola/imgfmt/app/TREFile.java: Back out mistaken checking that broke the map. 2007-11-06 steve * src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Characters between 1d and 1f can just go through unchanged. * Makefile, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java: More reliably work with QLandkarte. Calculation of the size of the TRE subdiv region was wrong when the lowest level was not 0, such as happens in the overview map. 2007-11-05 steve * ChangeLog, Makefile, src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java: Version 0.3 works like 0.4 and recentish files claim to be 0.3 so include them in the 0.4 support * src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/TestTdb.java: Don't repeat copyright statements. 2007-11-04 steve * doc, test: Add some ignores 2007-11-03 steve * src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/plugin/MapReader.java: OSM api v0.5 is now the default format. 0.4 is still supported and detected automatically so there is not much difference. * src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/plugin/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Allow reading from zip compressed files. This is done by file extension and not the actual type of file. * .: Initialized merge tracking via "svnmerge" with revisions "1-343" from https://svn.parabola.me.uk/svn/mkgmap/branches/lang 2007-11-02 steve * src/uk/me/parabola/imgfmt/app/TYPFile.java: Skeleton code added 2007-10-29 steve * Makefile, src/uk/me/parabola/imgfmt/FileSystemParam.java, src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/fs/DirectoryEntry.java, src/uk/me/parabola/imgfmt/fs/FileSystem.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/BlockTable.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/HeaderDirent.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/log/UsefulFormatter.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/TestAll.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/plugin/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/tdbfmt/Block.java, test, test/java, test/java/test: Merged in the img file reading support. The underlying img read code (at the imgfmt.sys level) has been heavily changed, so watch out. Appears to give the same result files as before though. In addition to read support, you should find that blocksizes other than 512 now actually work. Combining .img files into a gmapsupp.img file is now possible, although not implemented just yet. 2007-10-25 steve * src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: Add line number and column number on parser errors. * src/uk/me/parabola/mkgmap/main/MakeMap.java: Now that we can have more than one file on the command line, we should deal with errors in induvidual files and then go on to the next. (bug reported by User:Lambertus) 2007-10-21 steve * src/uk/me/parabola/mkgmap/general/MapBuilder.java: Was adding one instead of subtracting when making the number of bits for the top invible level. Thanks to Petr Schönmann for pointing this out 2007-10-20 steve * src/uk/me/parabola/imgfmt/app/TREFile.java: Removed unused statement. * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Add more comments. * src/uk/me/parabola/imgfmt/app/TREFile.java: Account for the size of the final RGN pointer, so that the TRE section size is correct. 2007-10-18 steve * ChangeLog, Makefile: Update changelog file. * src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java: Remove deprecated tag, its more just unused. * src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/mkgmap/general/MapBuilder.java: Fix the markers at the end of a group of subdivisions. I was only putting the end marker on the last divsion in a level. Each set of divisions that has the same parent should have an end marker though. This fixes the 'Find' bug, and seems to make the map faster in dense areas. * src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java: Prevent too many levels being used as this leads to maps that cause a crash. 2007-10-15 steve * src/uk/me/parabola/mkgmap/general/MapBuilder.java: Split up long lines, this will help with coastlines, contours etc as there appears to be a limit of around 250 points that you can have in a line on the garmin devices. * src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Implement the EndLevels (and it varients) and add the old RGN10 etc section names. 2007-10-14 steve * Makefile, resources/map-features.csv, resources/osm_garmin_map.csv, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Hack to display contours with thier heights. * src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java: Add coastlines and cities to the overview. I guess this should be driven by a full map-features file. * src/uk/me/parabola/mkgmap/main/CommandArgs.java: Command argument can now be read from a file, including input files and further files to read options from. * src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/MapBuilder.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/Way4.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, src/uk/me/parabola/mkgmap/reader/plugin/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java, src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java: Merged in code cleanup from the gui branch. That branch is now merged up to r299 2007-10-12 steve * Makefile, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: If a node that is part of a way is missing, then dont add a null point... 2007-10-07 steve * doc/features.txt: Will be list of features. 2007-10-06 steve * ., ChangeLog, Makefile, resources/MANIFEST.MF, resources/README, src/uk/me/parabola/imgfmt/app/InternalFiles.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/labelenc/Bit10Encoder.java, src/uk/me/parabola/log/UsefulFormatter.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapBuilder.java, src/uk/me/parabola/mkgmap/general/MapDataSource.java, src/uk/me/parabola/mkgmap/main/ArgumentProcessor.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/FilenameProcessor.java, src/uk/me/parabola/mkgmap/main/Main.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MapEvents.java, src/uk/me/parabola/mkgmap/main/MapOption.java, src/uk/me/parabola/mkgmap/main/MapProcessor.java, src/uk/me/parabola/mkgmap/main/OverviewMapBuilder.java, src/uk/me/parabola/mkgmap/main/TestAll.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/overview, src/uk/me/parabola/mkgmap/reader/overview/OverviewMap.java, src/uk/me/parabola/mkgmap/reader/overview/OverviewMapDataSource.java, src/uk/me/parabola/mkgmap/reader/overview/package.html, src/uk/me/parabola/mkgmap/reader/plugin/MapperBasedMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Merged in the overview/tdb branch. * doc/map-features.txt: Customising the map. 2007-10-04 steve * doc/map-features.txt, doc/mkgmap-man.txt: First stab at some documentation 2007-10-01 steve * ChangeLog: Update the changelog file. 2007-09-25 steve * Makefile: makefile changes 2007-09-24 steve * src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPolygonMap.java, src/uk/me/parabola/mkgmap/main/TestAll.java, src/uk/me/parabola/mkgmap/main/package.html: Removed test programs that are replaced by the test-map:all-elements map and indeed probably don't even work any more. * src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Code cleanup. 2007-09-23 steve * resources/map-features.csv, resources/osm_garmin_map.csv: fix previous change and made the map-features file. * resources/osm_garmin_map.csv: Slight tweek to reduce the number of towns at low res. * src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java: Removed imports that are not used any more. * src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Not setting the resolution in the default (old) case. * src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/StructuredInputStream.java, src/uk/me/parabola/tdbfmt/StructuredOutputStream.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Javadoc and code tidy up. * src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/StructuredOutputStream.java, src/uk/me/parabola/tdbfmt/TdbFile.java, src/uk/me/parabola/tdbfmt/TestTdb.java: Now can write out the tdb file so it is identical to the file that was read in. Not particularly useful, but shows that all is working. * resources/map-features.csv, resources/osm_garmin_map.csv: Tweeked map features. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java: Add warning for when a region is overflowing. * src/uk/me/parabola/mkgmap/reader/test/AllElements.java: wasn't showing all the lines. * src/uk/me/parabola/tdbfmt/TdbFile.java, src/uk/me/parabola/tdbfmt/Test.java, src/uk/me/parabola/tdbfmt/TestTdb.java: Some tidying around tdb test. * src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/EndOfFileException.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/StructuredInputStream.java, src/uk/me/parabola/tdbfmt/TdbFile.java, src/uk/me/parabola/tdbfmt/TestTdb.java: Javadoc additions * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/main/TestAll.java: Fuller test coverage. * src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightBlock.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/StructuredInputStream.java, src/uk/me/parabola/tdbfmt/TdbFile.java: Full decoding of the TDB file now. * src/uk/me/parabola/tdbfmt/Block.java, src/uk/me/parabola/tdbfmt/CopyrightSegment.java, src/uk/me/parabola/tdbfmt/DetailMapBlock.java, src/uk/me/parabola/tdbfmt/EndOfFileException.java, src/uk/me/parabola/tdbfmt/HeaderBlock.java, src/uk/me/parabola/tdbfmt/OverviewMapBlock.java, src/uk/me/parabola/tdbfmt/StructuredInputStream.java, src/uk/me/parabola/tdbfmt/TdbFile.java, src/uk/me/parabola/tdbfmt/Test.java, src/uk/me/parabola/tdbfmt/package.html: Initial code for the TDB file. As there are no programs that simply print the contents out, then the first task is to be able to do this so that we can check that we are producing the correct things. * src/uk/me/parabola/imgfmt/fs/ImgChannel.java: javadoc clarification 2007-09-22 steve * src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestElementMap.java, src/uk/me/parabola/mkgmap/reader/plugin/MapReader.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java: You can now set the level definitions from the command line and choose another map-features file too. --map-features=file --levels=0:24,1:22,2:20 (or you can use 0=24 etc) * src/uk/me/parabola/mkgmap/ConfiguredByProperties.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/PropertyConfiguredReader.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Osm4MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmXmlHandler.java, src/uk/me/parabola/mkgmap/reader/plugin, src/uk/me/parabola/mkgmap/reader/plugin/MapReader.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java: You can now set the level definitions from the command line and choose another map-features file too. --map-features=file --levels=0:24,1:22,2:20 (or you can use 0=24 etc) * src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java: Implement the selective node creation for osm5, the same as for osm4 * resources/feature_map.csv, resources/map-features.csv, resources/osm_garmin_map.csv, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Now have a new name for the feature map file map-features.csv * resources/feature_map.csv, scripts/mk_map_table.py: Add extra column to the feature map file. * resources/garmin_feature_list.csv, resources/osm_garmin_map.csv, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java: Now read the resolutions from the feature map file. 2007-09-20 steve * src/uk/me/parabola/mkgmap/main/CommandArgs.java: typo fix 2007-09-19 steve * src/uk/me/parabola/log/Logger.java: Logging routines more consistant. 2007-09-18 steve * src/uk/me/parabola/log/Logger.java: Logging routines more consistant. * Makefile, src/uk/me/parabola/mkgmap/reader/osm/OSM5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmXmlHandler.java: Name change for OSM --> Osm 2007-09-15 steve * src/uk/me/parabola/log/UsefulFormatter.java: The formatter must be public so that the LogManager can see it. * src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java: Better lookup of features by stepping through tags and not by stepping through the list of features. Most nodes are just parts of a line. Try to prevent converting nodes that are definitly not stand alone (eg just have a created_by tag). Saves about 5% * Makefile, src/uk/me/parabola/mkgmap/main/MakeTestElementMap.java, src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/reader/osm/package.html: Documentation and small changes. 2007-09-13 steve * Makefile, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin2Encoder.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/log/UsefulFormatter.java, src/uk/me/parabola/mkgmap/general/LevelFilter.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeTestElementMap.java, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/OSM5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java: Code tidy up. * src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java: Fix spelling. (Bruce Cowan) * src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/package.html, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Made many classes package local again, now that I've recombined the OSM readers into the one package. * src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/osm/OSM5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Way5.java, src/uk/me/parabola/mkgmap/reader/osm5: Remove osm5 directory and move all to the osm package. 2007-09-12 steve * src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/Node4.java, src/uk/me/parabola/mkgmap/reader/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm5/Node5.java, src/uk/me/parabola/mkgmap/reader/osm5/OSM5XmlHandler.java: Got rid of Node4 and 5 as they were just the same anyway. The interface went as well. * resources/garmin_feature_list.csv, resources/osm_garmin_map.csv: Extensive work-through of features from going through test-map:all-elements 2007-09-11 steve * ChangeLog, Makefile: New changelog checked in. * scripts/mk_map_table.py: Change needed to create map_features * resources/feature_map.csv, resources/garmin_feature_list.csv, resources/osm_garmin_map.csv: A few more features added. Basic city/town support, but can be better and use the indexed point feature of the maps. * resources/logging.properties, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/Node4.java, src/uk/me/parabola/mkgmap/reader/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/Way4.java, src/uk/me/parabola/mkgmap/reader/osm5, src/uk/me/parabola/mkgmap/reader/osm5/Node5.java, src/uk/me/parabola/mkgmap/reader/osm5/OSM5XmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm5/Osm5MapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm5/Way5.java: Added support for api version 0.5. Usage is transparent - it works out the difference between 0.4 and 0.5 automatically and uses the right reader. * src/uk/me/parabola/mkgmap/general/MapSplitter.java: Remove assertion so will compile out of svn 2007-09-09 steve * src/uk/me/parabola/log/Logger.java: Make default for static setup SEVERE * src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Made a lot of changes to the way that the subdivisions are split. It should now be the case that there are no empty sections within the RGN files ie if there are no points then the flag to say there are points will not be set. Doesn't appear to fix the 'find' bug. Does seem to fix the problem shown by imgdecode, where at lower-res levels there are wierd all over the place polygons. Not really tested much at all though. * src/uk/me/parabola/mkgmap/general/MapElement.java: Comments to explain min resolution better and the direction it is going in. * src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Update the polish input format, so that it places elements at the levels specified in the file and not at the default levels. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java: javadoc etc. * src/uk/me/parabola/log/Logger.java: Print warning if log config file could not be opened. * src/uk/me/parabola/imgfmt/app/Subdivision.java: Round the sizes before shifting them. * build.xml, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/log/UsefulFormatter.java: Convert the logging to use j.u.l underneath. You can still use varargs in the logging calls and the interface is just the same (use debug() instead of fine() etc). Was it worth it? Probably not. Should be able to selectively switch on some logging now though. 2007-09-08 steve * src/uk/me/parabola/imgfmt/app/RGNFile.java: Cosmetic changes * src/uk/me/parabola/mkgmap/reader/test/ManyPoints.java: Checkin deleted file after re-naming * src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/TestPoints.java: A test map to look into the 'find' bug. 2007-09-03 steve * src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/PropertyConfiguredReader.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/ManyPoints.java: The test map I am using to debug the 'find' problem and missing points problem. * src/uk/me/parabola/mkgmap/main/CommandArgs.java: Make public * src/uk/me/parabola/mkgmap/main/CommandArgs.java: Remove comment that I don't really believe in. * src/uk/me/parabola/mkgmap/main/MakeMap.java: Fix call to function that is not checked in. * src/uk/me/parabola/mkgmap/general/MapSplitter.java: Comment changed. * src/uk/me/parabola/mkgmap/main/MakeMap.java: Remove adding the dummy overview. It doesn't get added to the end since we now sort them, and the lack of sorting is probably the reason that they were added in the first place(?) * src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java: Get the right values for the max number of lines and shapes. 2007-09-02 steve * src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestElementMap.java, src/uk/me/parabola/mkgmap/reader/MapReader.java, src/uk/me/parabola/mkgmap/reader/test, src/uk/me/parabola/mkgmap/reader/test/AllElements.java, src/uk/me/parabola/mkgmap/reader/test/ElementTestDataSource.java, src/uk/me/parabola/mkgmap/reader/test/package.html: New test data source. It generates test maps. Try it by using TEST:ALL-ELEMENTS as the input file name. * src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPolygonMap.java: Remove writeOverviews from superclass, make a call in the one place it is used and remove all other usages. * src/uk/me/parabola/imgfmt/FileNotWritableException.java: Fix typo in comment * src/uk/me/parabola/imgfmt/app/labelenc/Bit10Encoder.java: The so-called 10-bit encoder, spoils the package dependancies and is probably not even correct. I'd imagine that they would just use unicode for other international character sets. * src/uk/me/parabola/imgfmt/FileNotWritableException.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Fix exception handling on unwritable files to be clearer. * src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: The input format interface now has two new methods. One to determine if a given file is supported, and one to return suitable map levels for the map. * resources/README: Added readme file. * src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/reader/MapReader.java: Separate out the code to determine what kind of input file is in use. This will allow a more plugin type approach in the future. * Makefile, src/uk/me/parabola/mkgmap/main/MakeMap.java: 1. Code to simplify the lines before they are written. 2. Change needed for the moving of the reader classes. * src/uk/me/parabola/imgfmt/FileExistsException.java, src/uk/me/parabola/imgfmt/app/package.html, src/uk/me/parabola/imgfmt/fs/DirectoryEntry.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/package.html, src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/general/package.html, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/package.html, src/uk/me/parabola/mkgmap/reader/polish/package.html: Many javadoc improvements. * src/uk/me/parabola/mkgmap/general/LevelInfo.java, src/uk/me/parabola/mkgmap/osm, src/uk/me/parabola/mkgmap/polish: Move LevelInfo into the general directory. * src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/Node.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java, src/uk/me/parabola/mkgmap/polish/PolishMapDataSource.java, src/uk/me/parabola/mkgmap/reader, src/uk/me/parabola/mkgmap/reader/osm, src/uk/me/parabola/mkgmap/reader/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Element.java, src/uk/me/parabola/mkgmap/reader/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/reader/osm/Node.java, src/uk/me/parabola/mkgmap/reader/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/reader/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java, src/uk/me/parabola/mkgmap/reader/osm/Segment.java, src/uk/me/parabola/mkgmap/reader/osm/Way.java, src/uk/me/parabola/mkgmap/reader/osm/package.html, src/uk/me/parabola/mkgmap/reader/polish, src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java: Move input formats into their own directory. Will make it clearer how to add new input formats, such as shape files. 2007-09-01 steve * src/uk/me/parabola/mkgmap/polish, src/uk/me/parabola/mkgmap/polish/PolishMapDataSource.java: Add the polish format as an input choice. * src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Re-allow 5 field files again. 2007-08-31 steve * src/uk/me/parabola/imgfmt/app/Map.java: Give a message when it is not possible to create the output map file. 2007-08-27 steve * src/uk/me/parabola/mkgmap/general/MapDetails.java: Imports re-arranged. * src/uk/me/parabola/mkgmap/general/MapSplitter.java: don't repeat code in the constructors. 2007-08-25 steve * Makefile, README, src/uk/me/parabola/imgfmt/app/labelenc/Latin2Encoder.java, src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/package.html: Small tidy ups for release. * src/uk/me/parabola/mkgmap/general/MapDetails.java: Check for empty areas and lines. Fixes bug rendering: http://openstreetmap.gryph.de/germany/germany-070823.osm.bz2 * src/uk/me/parabola/imgfmt/app/Area.java: Make sure that areas never have a zero width or height. Avoids the problem below. Bearbeite Kachelnummer: 63253506 Exception in thread "main" java.lang.ArithmeticException: / by zero at uk.me.parabola.mkgmap.general.MapArea.pickArea(MapArea.java:361) * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: We need to make sure that points are included in the calculation of the size of the area. Otherwise it is posible for the point to be outside the map area altogether. If it happens to outside to the west or south then you get the error below. Bearbeite Kachelnummer: 63247525 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -9 at uk.me.parabola.mkgmap.general.MapArea.pickArea(MapArea.java:373) * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java: Fix ensureSize() properly so that we never run out of space. Bearbeite Kachelnummer: 63243936 Exception in thread "main" java.nio.BufferOverflowException at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:165) 2007-08-21 steve * src/uk/me/parabola/mkgmap/general/MapArea.java: Re-instated part of the RGN overflow change. * src/uk/me/parabola/mkgmap/general/MapArea.java: Remove println that should have been removed. * ChangeLog, Makefile: Changelog and makefile changes only * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java: Possible fix for overflow in output buffer. * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java: Attempted fix for overflowing RGN section. 2007-08-19 steve * Makefile: Add note that this is not really used to build * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java: Allow coastlines to show up at all resolutions. * resources/feature_map.csv, resources/garmin_feature_list.csv, resources/osm_garmin_map.csv: Fix the feature lists which seemed to be populated with all kinds of weird things. * src/uk/me/parabola/imgfmt/app/LBLFile.java: Improve description on javadoc for newLabel (now that it doesn't always return a new lable) * src/uk/me/parabola/imgfmt/app/LBLFile.java: Keep a cache of label names so that we do not create multiple labels for the same piece of text. Greatly reduces the size of the label section. * src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java: Allocate elements to sub-divisions based on the mid-point of the element rather than the first point in the line/polygon. This will create less overlapping of the sub-divisions, which may make the map faster on the Garmin units. To do reduce sub-division overlapping further will require splitting lines. It may not be worth reducing overlap either. 2007-08-15 steve * src/uk/me/parabola/mkgmap/main/ExitException.java: This should have been removed by the previous commit. * ChangeLog, src/uk/me/parabola/mkgmap/ExitException.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Move ExitException to remove cycle in the package structure. 2007-06-23 steve * src/uk/me/parabola/mkgmap/general/MapArea.java: Getting rid of zero length lines. * src/uk/me/parabola/imgfmt/app/labelenc/package.html, src/uk/me/parabola/imgfmt/fs/package.html, src/uk/me/parabola/imgfmt/package.html, src/uk/me/parabola/mkgmap/main/package.html: Added and fixed package level javadoc. 2007-06-17 steve * src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java: Comments and add a toString method to Coord 2007-06-10 steve * Makefile, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/Way.java: Tidy up and tweeking of hardwired parameters. * Makefile, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Had the wrong mask for the level, so any level above 3 would mess things up. Now working with 5 levels. Time to make it configurable... * .: Tidied up the list of ignored files. * Makefile, src/uk/me/parabola/imgfmt/app/Subdivision.java: Merge large file fixes in from stable branch. 2007-06-09 steve * src/uk/me/parabola/mkgmap/general/MapElement.java: Add some more hardwired resolutions. 2007-06-07 steve * src/uk/me/parabola/imgfmt/sys/Directory.java: Increase number of directory blocks. 2007-05-29 steve * src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Deleted file and remove unused import 2007-05-13 steve * Makefile, resources/garmin_feature_list.csv, resources/osm_garmin_map.csv, scripts/mk_map_table.py, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Input files for feature_map.csv and program to create. Moved away from the files in osmgarminmap, but garmin_feature_list.csv is a copy of feature-list.csv from there. * resources/feature_map.csv: New feature map with many more entries and fully sorted. Contributed by Roozbeh Pournader 2007-05-09 steve * Makefile, resources/feature_map.csv, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OsmMapDataSource.java: Zoomability now working for large maps eg London. Still basic, but now just really a matter of tuning it up. 2007-03-29 steve * src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Zoomability now working for large maps eg London. Still basic, but now just really a matter of tuning it up. 2007-03-25 steve * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapDataSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Working 'zoomable' map. Very basic, you see exactly the same things at the lower resolution levels as the higher ones. Its now just a simple matter of filtering what is wanted at each level... * src/uk/me/parabola/imgfmt/app/InternalFiles.java, src/uk/me/parabola/imgfmt/app/Polygon.java: Add some javadoc. 2007-03-24 steve * src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/mkgmap/general/LoadableMapDataSource.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapDataSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Split MapDataSource to allow it to be implemented by MapArea * src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java: Keep track of how many elements are at each resolution. * src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Pushed bounding box code into line and polyline as it is not needed on points. 2007-03-04 steve * src/uk/me/parabola/mkgmap/general/LevelFilter.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Level loop in place, although it will not work if more than one level in there. * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Split out making top level subdivision. 2007-03-03 steve * ChangeLog, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/Way.java: Merged back from branch. - Use the ref tag where available - Works for large areas (really this time). Both problems pointed out by Phillip Barnett. * Makefile, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Options added preparation for zoomability. 2007-02-10 steve * src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Added space before equals sign. 2007-02-08 steve * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/Element.java: Removed a number of the TODO's and removed some dead code. * src/uk/me/parabola/log/Logger.java: May as well remove concurrent hash map it will then run with gcj. Its ten times slower though. 2007-02-07 steve * src/uk/me/parabola/imgfmt/FormatException.java, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/Segment.java: Deleted a lot of unused stuff, even if it would be good for debugging. 2007-02-06 steve * build.xml: Build problem * ChangeLog, README, build.xml: Final changes for release. * src/uk/me/parabola/imgfmt/sys/ImgFS.java: Fix annoying problem where overwriting a bigger file leaves the new file unworkable, even if it would be alright otherwise. * src/uk/me/parabola/mkgmap/general/MapArea.java: Keep the full bounds of empty areas. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/sys/Dirent.java: Small tidy up. 2007-02-05 steve * Makefile: Just a makefile change * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/sys/Dirent.java: Fixed bug in the write strategy that I'd fixed before, but lost. It looks like the location of the sub-file part is incorrect in the documentation, although correct in the output of imgdecode. I modified Dirent so that the results were good in imgdecode. It looks like the 0x3 needs to go *before* the part number in the 'special' dirent. 2007-02-04 steve * src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java: Allow extra space, in case the name is just one funny character. Not really sure about this, just happened that there was an error. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java: Grow the buffer for any size of file. * src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/BlockTable.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/SysDirEntry.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/general/MapArea.java: Code tidy up. * src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/Way.java: I discovered that debug was really happening when it shouldn't, just not being written to the file. The Coord.toString method was taking considerable time. Anyway now whole of london takes 7 seconds, down from 27 seconds. * Makefile, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/BlockTable.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/SysDirEntry.java: Now working on the Garmin for the whole of london. 2007-02-03 steve * src/uk/me/parabola/mkgmap/general/MapArea.java: Format long argument list. * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/TestAll.java: Tidy up with added comments too. * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Working fully with large areas. 2007-02-02 steve * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Apears to work in QLandkarte anyway on the big file that will not fit into one subdiv. 2007-01-31 steve * Makefile, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: The basic area splitter is now done. 2007-01-22 steve * src/uk/me/parabola/imgfmt/app/Subdivision.java: May as well uncomment the old methods, rather than create new ones ;) * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/InternalFiles.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/mkgmap/general/MapArea.java, src/uk/me/parabola/mkgmap/general/MapSplitter.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPolygonMap.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/Node.java: Massive changes to support multiple subdivisions. Many methods moved around into more logical classes, so the code just looks better anyway. Program still works in spite of all the changes. 2007-01-21 steve * src/org: Get rid of empty directories. 2007-01-20 steve * src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/Way.java: Set the direction flag properly now so that it goes into the map. * src/uk/me/parabola/mkgmap/general/MapDataSource.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Rename MapSource to MapDataSource to avoid confusion with garmin product * src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Comments etc while thinking about changes to allow multiple divisions. * build.xml: Set target in build.xml to 1.5 to prevent requiring 1.6. 2007-01-19 steve * ChangeLog, README: Final changes for release. * src/uk/me/parabola/imgfmt/sys/Dirent.java: Logging message change * src/uk/me/parabola/mkgmap/main/CommandArgs.java: Added explicit --latin1 option * src/uk/me/parabola/imgfmt/app/LBLFile.java: Make an explicit --latin1 option 2007-01-16 steve * src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java: Null terminate string in simple8 format. * Makefile, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/TREFile.java: Found problem with polygons not showing up. It would appear that the overview sections have to be sorted by value. So sort them, and points and lines for good measure too, as it may well be the same for them. * src/uk/me/parabola/log/Logger.java: Added a few comments 2007-01-14 steve * Makefile, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/EncodedText.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin1Encoder.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/TestAll.java, src/uk/me/parabola/mkgmap/osm/Node.java, src/uk/me/parabola/tdbfmt: Code cleanup * src/uk/me/parabola/imgfmt/app/labelenc, src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Bit10Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/CharacterEncoder.java, src/uk/me/parabola/imgfmt/app/labelenc/EncodedText.java, src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin1Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Latin2Encoder.java, src/uk/me/parabola/imgfmt/app/labelenc/Simple8Encoder.java, src/uk/me/parabola/mkgmap/main/TestAll.java: Basic i18n code done. Now for testing it. * Makefile, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Label10.java, src/uk/me/parabola/imgfmt/app/Label6.java, src/uk/me/parabola/imgfmt/app/LabelLatin1.java, src/uk/me/parabola/imgfmt/app/LabelLatin2.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestLang10Map.java, src/uk/me/parabola/mkgmap/main/MakeTestLangMap.java, src/uk/me/parabola/mkgmap/main/TestAll.java: Major surgury on the label system, now that it is a bit clearer how internationalisation might work. 2007-01-13 steve * src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/TestAll.java: Test run through different scenarios. Keeps the code coverage up now that we are adding options. 2007-01-10 steve * src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Label10.java, src/uk/me/parabola/imgfmt/app/Label6.java, src/uk/me/parabola/imgfmt/app/LabelLatin1.java, src/uk/me/parabola/imgfmt/app/LabelLatin2.java: Reorganise label text so that we can deal with different languages. 2007-01-09 steve * build.xml: Make feature list get into the built jar. 2007-01-07 steve * ChangeLog: Change log updated * src/uk/me/parabola/mkgmap/main/MakeMap.java: ChangeLog updated. * README, resources/feature_map.csv, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/mkgmap/main/package.html: Getting ready for a release. * src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Fix treatment of points. They now show up again. * src/uk/me/parabola/imgfmt/app/Point.java: Fix so that points are now back on the map, rather than being located way away. * src/uk/me/parabola/imgfmt/app/Label.java: Allow numbers in a name and experiment with 8bit encoding of labels. 2007-01-06 steve * src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPolygonMap.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java: Code clean up. * src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Changes to add clarity and fix low zoom rendering. 2007-01-02 steve * Makefile, resources/feature_map.csv, scripts/mk_map_table.py, src/uk/me/parabola/mkgmap/main/AbstractTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPointMap.java, src/uk/me/parabola/mkgmap/main/MakeTestPolygonMap.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/Way.java: Code to create artificial maps that shows all different polygon or node types. This will allow us to complete the feature map. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/PointOverview.java, src/uk/me/parabola/imgfmt/app/PolygonOverview.java, src/uk/me/parabola/imgfmt/app/PolylineOverview.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: The overview section is now generated completely from the elements that are actually present in the map. Not much visible difference, but will mean that all polygons show up once we add them to the features list and all the POI categories will show up and none will be empty. 2007-01-01 steve * src/uk/me/parabola/mkgmap/main/MakeMap.java: Remove unused varaibles. * src/uk/me/parabola/mkgmap/main/CommandArgs.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: We now have a separate class to deal with the arguments. This is getting ready for further changes, doesn't have much effect yet - except you can finally change the mapname. * ChangeLog, Makefile: Group changelog entries by day instead * Makefile: The makefile I've been using for odds and ends. * ChangeLog: Re-paragraphed * src/uk/me/parabola/mkgmap/main/MakeMap.java: Moved adding of the overview sections out of the routine to make the divisisions. Both because it doesn't belong their and in preparation for obtaining the overview from somewhere definitive. * ChangeLog: Added the changelog to the project. * src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/main/ExitException.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Minor cleanups. * build.xml, resources/feature_map.csv, scripts/mk_map_table.py, src/uk/me/parabola/mkgmap/osm/FeatureListConverter.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: The map featues are now driven by a file. As it turns out though the OSMGarminMap list of features doesn't contain all the features I was already using. 2006-12-31 steve * README: Updated readme for release. * src/uk/me/parabola/mkgmap/main/MakeMap.java: If the map info is going to display as the map name, then lets just put the map name there. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/fs/FileSystem.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapShape.java, src/uk/me/parabola/mkgmap/main/ExitException.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/Way.java: Big code clean up. * src/uk/me/parabola/log/Logger.java: Simple logger. 2006-12-30 steve * src/uk/me/parabola/imgfmt/app/LinePreparer.java: Fixed bug where base goes over 9. Able to remove a couple of fields as a result. * src/uk/me/parabola/log/Logger.java: Implemented a bit of logging. Will need to be made conditional. * src/uk/me/parabola/mkgmap/osm/Way.java: Fixed the segment ordering bug. * src/uk/me/parabola/mkgmap/osm/Element.java: Check for null on get. * src/uk/me/parabola/mkgmap/osm/Element.java: No tag saved for created_by and don't create the hashmap if it is not needed. * LICENCE.log4j, build.xml, external.properties, resources/MANIFEST.MF, resources/log4j-dist.properties, resources/log4j.properties, src/org, src/org/apache, src/org/apache/log4j, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/fs/package.html, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/log, src/uk/me/parabola/log/Logger.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/Way.java: Removed log4j dependancy. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polygon.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/Node.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java: Mostly a white space change. Have been experimenting with getting the map description to display instead of the map info as the map name. * src/uk/me/parabola/imgfmt/app/Label.java: Added many special characters to the translation. * src/uk/me/parabola/mkgmap/main/MakeMap.java: Fix inconsistant indentation 2006-12-29 steve * ., doc, scripts, scripts/checksum.py, scripts/imgfile.py, scripts/munger.py, scripts/namesum.py: added scripts directory for python scripts plus doc base directory. Added more to svn:ignore * src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java: Comments toString method. Stuff like that. 2006-12-28 steve * src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java: adding new features. * src/uk/me/parabola/imgfmt/FormatException.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/mkgmap/FormatException.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Move FormatException to its correct package. Prevents a dependancy loop 2006-12-27 steve * README: Update the readme file a bit for the release * README, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java: Added some cool features, rail, woods, water. Made them show up by adding to overview sections where necessary. * src/uk/me/parabola/mkgmap/osm/Way.java: Bug fix to make the spliting into separate lines work better without breaking into all 1 segment lengths. This will all be re-written though soon. * src/uk/me/parabola/imgfmt/app/Label.java: fix compilation. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/fs/FileSystem.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgFS.java: Changed names of FSOps and FileSystem. 2006-12-26 steve * src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/Node.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Code tidy up after adding points. * src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapElement.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapPoint.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/Element.java, src/uk/me/parabola/mkgmap/osm/Node.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java, src/uk/me/parabola/mkgmap/osm/package.html: Add points to the map. Working. 2006-12-24 steve * src/uk/me/parabola/mkgmap/osm/CodedConverter.java: Added a few more feature conversions. Used the osmgarminmap feature list. * src/uk/me/parabola/imgfmt/app/LinePreparer.java, src/uk/me/parabola/imgfmt/app/Polyline.java: Separated out the line preparation code into its own top level class 2006-12-23 steve * src/uk/me/parabola/imgfmt/app/Subdivision.java: put shift into constructor and remove unused getters. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/TREFile.java: Code tidy * src/uk/me/parabola/imgfmt/app/Polyline.java: Fix for negative number of bits. * .: Ignore more junk in top directory * src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java: Problem with the devision pointers needed the header size taken off too. Now polygons work. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java: Code clean up. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java: Important fix to get the size of the files correct. Needed as unit reads to the end of the file and we don't want to read a bung of zeros. Polygons draw (but no colouring or identification) but cause all the lines to have no information associated with them. When you hover over there is no 'tooltip' or when you click it just says there is nothing there. * src/uk/me/parabola/mkgmap/main/MakeMap.java: Fix imports to not use * * resources/log4j.properties, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapShape.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Code for adding polygons is in. Doesn't work if you enable the polygons but regression test is fine if they are not enabled. 2006-12-22 steve * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polygon.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java: restructured ready for adding points and polygons. Now the Map class is the center of all activity. There is no need to leak the TRE,LBL and RGN files outside of the Map class. 2006-12-21 steve * LICENCE, build.xml: Add GPL * README, build.xml: Made a half decent README. * build.xml, resources/log4j-dist.properties, resources/log4j.properties: Changed logfile and jar names to be consistant with project name * build.xml: Build a usable dist directory. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/mkgmap/FormatException.java, src/uk/me/parabola/mkgmap/osm/Way.java: Some documentation additions and changed format exception to runtime * src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java: Don't need to be public. * LICENCE.log4j: add licence for log4j. * resources/log4j-dist.properties: added 2006-12-20 steve * README, build.xml, resources/MANIFEST.MF, src/uk/me/parabola/imgfmt/app/package.html, src/uk/me/parabola/imgfmt/fs/package.html, src/uk/me/parabola/imgfmt/sys/package.html, src/uk/me/parabola/mkgmap/general/package.html, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/package.html: Fix up build, javadoc etc for release. * src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Polyline.java: Placed isDebugEnabled around some of the frequent messages. * src/uk/me/parabola/mkgmap/osm/CodedConverter.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java: Prepare for a converter that is not hard coded. Plus added a few road types. * src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/OsmConverter.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Separate out the conversion to a separate class. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Code tidy up. * src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/general/package.html, src/uk/me/parabola/mkgmap/osm/package.html: Documentation and cleanup. * src/uk/me/parabola/mkgmap/osm/ReadOsm.java: Map source is now the source of the copyright message to display. * src/uk/me/parabola/mkgmap/main/MakeTestMap.java: Fix the test program too. * src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/mkgmap/MapCollector.java, src/uk/me/parabola/mkgmap/MapDetails.java, src/uk/me/parabola/mkgmap/MapLine.java, src/uk/me/parabola/mkgmap/MapSource.java, src/uk/me/parabola/mkgmap/general, src/uk/me/parabola/mkgmap/general/MapCollector.java, src/uk/me/parabola/mkgmap/general/MapDetails.java, src/uk/me/parabola/mkgmap/general/MapLine.java, src/uk/me/parabola/mkgmap/general/MapSource.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java: Improved the design by making clear what the collector actually is. It is just part of the generic map handling. * src/uk/me/parabola/mkgmap/main/ExitException.java, src/uk/me/parabola/mkgmap/main/MakeMap.java: Use exception for errors leading to exit of the progrm * src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/mkgmap/Filter.java, src/uk/me/parabola/mkgmap/Highway.java, src/uk/me/parabola/mkgmap/MapCallbacks.java, src/uk/me/parabola/mkgmap/MapCollector.java, src/uk/me/parabola/mkgmap/MapData.java, src/uk/me/parabola/mkgmap/MapDetail.java, src/uk/me/parabola/mkgmap/MapDetails.java, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java: Big cleanup of the code. 2006-12-19 steve * src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java: Some attempt to fix up mis-ordered segments. Pretty good and usable map results. Before the big cleanup. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java, src/uk/me/parabola/mkgmap/Filter.java, src/uk/me/parabola/mkgmap/FormatException.java, src/uk/me/parabola/mkgmap/Highway.java, src/uk/me/parabola/mkgmap/MakeTestMap.java, src/uk/me/parabola/mkgmap/MapCallbacks.java, src/uk/me/parabola/mkgmap/MapCollector.java, src/uk/me/parabola/mkgmap/MapData.java, src/uk/me/parabola/mkgmap/MapDetail.java, src/uk/me/parabola/mkgmap/MapDetails.java, src/uk/me/parabola/mkgmap/MapLine.java, src/uk/me/parabola/mkgmap/MapSource.java, src/uk/me/parabola/mkgmap/main, src/uk/me/parabola/mkgmap/main/MakeMap.java, src/uk/me/parabola/mkgmap/main/MakeTestMap.java, src/uk/me/parabola/mkgmap/osm/OSMXmlHandler.java, src/uk/me/parabola/mkgmap/osm/ReadOsm.java, src/uk/me/parabola/mkgmap/osm/Segment.java, src/uk/me/parabola/mkgmap/osm/Way.java: Fixed case where all the same sign quantities should be saved as positive and not as twos compliment. Map now works. Remaining problems appear to be in unordered segments in the source. 2006-12-18 steve * src/uk/me/parabola/imgfmt/app/TREFile.java: Remove hacky, not understood, flags section. * src/uk/me/parabola/mkgmap/MakeTestMap.java: This is part of the working map generating. * src/uk/me/parabola/imgfmt/app/TREFile.java: Finally working with the short TRE header length. We should now be able to use any name. * src/uk/me/parabola/imgfmt/Utils.java: Fix byte ordering and subtrace 1900 from the year in the common header date. If the high bits are set in the date field the map does not load. 2006-12-17 steve * .: More ignored directories. * src/uk/me/parabola/imgfmt/app/Polyline.java: Use lon instead of lng 2006-12-16 steve * src/uk/me/parabola/mkgmap, src/uk/me/parabola/mkgmap/MakeTestMap.java, src/uk/me/parabola/mkgmap/MapSource.java, src/uk/me/parabola/mkgmap/img, src/uk/me/parabola/mkgmap/osm, src/uk/me/parabola/mkosmgmap: Package moved. * src/uk/me/parabola/mkosmgmap/osm, src/uk/me/parabola/mkosmgmap/osm/ReadOsm.java: Added the osm directory. * src/uk/me/parabola/mkosmgmap/MakeTestMap.java: And indeed lets add the code to make the test map. * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/BitWriter.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/mkosmgmap/MapSource.java, src/uk/me/parabola/mkosmgmap/img, src/uk/me/parabola/mkosmgmap/osm: Working test map with streets that test various features of the code. 2006-12-12 steve * src/uk/me/parabola/imgfmt/app/Polyline.java: Saving work as this is a complicated bit and may not work on it for a while. * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/Area.java, src/uk/me/parabola/imgfmt/app/Bounds.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/MapObject.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Writable.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/fs/package.html, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/package.html: Started on polylines. General javadoc rampage. 2006-12-11 steve * README, resources/log4j.properties, src/uk/me/parabola/imgfmt/app/Coord.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/Polyline.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/sys/Directory.java: Working but empty map. worked with points, but I am now going on to lines to get roads. * src/uk/me/parabola/imgfmt/app/Label.java: Fix the end of label marker/length. Before labels that were a multiple of 4 bytes were not ended. 2006-12-10 steve * src/uk/me/parabola/imgfmt/app/Bounds.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/Point.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/sys/FileNode.java: Oh well still not recognised. I've padded out the last block to be a full block. No go. 2006-12-09 steve * src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Overview.java, src/uk/me/parabola/imgfmt/app/Subdivion.java, src/uk/me/parabola/imgfmt/app/Subdivision.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/Writable.java, src/uk/me/parabola/imgfmt/app/Zoom.java: Interesting point, getting very close to having a 'complete' map, but still no joy in getting my unit to recognise it. * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java: Got a label referenced from the copyright section of the TRE header. * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Label.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/sys/ImgFile.java: Its all a bit neater now. 2006-12-07 steve * src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java: Somewhat more works now. * src/uk/me/parabola/imgfmt/app/Bounds.java, src/uk/me/parabola/imgfmt/app/BufferedWriteStrategy.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/Subdivion.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/WriteStrategy.java, src/uk/me/parabola/imgfmt/app/Zoom.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java: Got some zoom and subdivision classes Working on a write strategy to start with. Not in a working state. 2006-12-05 steve * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/TREFile.java: Something reasonable is now written into all the headers. No data at all whatsoever. 2006-12-03 steve * src/uk/me/parabola/imgfmt/Utils.java, src/uk/me/parabola/imgfmt/app, src/uk/me/parabola/imgfmt/app/ImgFile.java, src/uk/me/parabola/imgfmt/app/LBLFile.java, src/uk/me/parabola/imgfmt/app/Map.java, src/uk/me/parabola/imgfmt/app/RGNFile.java, src/uk/me/parabola/imgfmt/app/TREFile.java, src/uk/me/parabola/imgfmt/app/package.html, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/sys/BlockAllocator.java, src/uk/me/parabola/imgfmt/sys/BlockManager.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Got some kind of common headers being written out. * src/uk/me/parabola/imgfmt/FileExistsException.java, src/uk/me/parabola/imgfmt/FileSystemParam.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/sys/BlockAllocator.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/DirectoryEntryImpl.java, src/uk/me/parabola/imgfmt/sys/Dirent.java, src/uk/me/parabola/imgfmt/sys/FileNode.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/FileSystemParam.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Can create files. 2006-12-02 steve * resources/log4j.properties, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/fs/FileChannel.java, src/uk/me/parabola/imgfmt/fs/ImgChannel.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/DirectoryEntryImpl.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/FileSystemParam.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Pretty much the basic structure there for directory entries. * src/uk/me/parabola/imgfmt/fs/DirectoryEntry.java, src/uk/me/parabola/imgfmt/fs/FSOps.java, src/uk/me/parabola/imgfmt/fs/FileChannel.java, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/DirectoryEntry.java, src/uk/me/parabola/imgfmt/sys/DirectoryEntryImpl.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgFile.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Getting the interface structure better. * src/uk/me/parabola/imgfmt, src/uk/me/parabola/imgfmt/fs, src/uk/me/parabola/imgfmt/sys, src/uk/me/parabola/imgfmt/sys/Directory.java, src/uk/me/parabola/imgfmt/sys/DirectoryEntry.java, src/uk/me/parabola/imgfmt/sys/FileSystem.java, src/uk/me/parabola/imgfmt/sys/ImgFile.java, src/uk/me/parabola/imgfmt/sys/ImgHeader.java: Files really added to new location this time * src/uk/me/parabola/mkosmgmap/img/Directory.java, src/uk/me/parabola/mkosmgmap/img/DirectoryEntry.java, src/uk/me/parabola/mkosmgmap/img/FileSystem.java, src/uk/me/parabola/mkosmgmap/img/ImgFile.java, src/uk/me/parabola/mkosmgmap/img/ImgHeader.java: Files moved to new imgfmt sub-packages. 2006-11-30 steve * src/uk/me/parabola/mkosmgmap/img/ImgHeader.java: Corrected 'number of sectors' * src/uk/me/parabola/mkosmgmap/img/Directory.java, src/uk/me/parabola/mkosmgmap/img/DirectoryEntry.java, src/uk/me/parabola/mkosmgmap/img/FileSystem.java, src/uk/me/parabola/mkosmgmap/img/ImgHeader.java: Header finished, starting on the directory. 2006-11-28 steve * build.xml, src/uk/me/parabola/mkosmgmap/img/Directory.java, src/uk/me/parabola/mkosmgmap/img/FAT.java, src/uk/me/parabola/mkosmgmap/img/FileSystem.java, src/uk/me/parabola/mkosmgmap/img/ImgHeader.java, src/uk/me/parabola/mkosmgmap/img/PartitionTable.java: progress on the header. 2006-11-26 steve * ., README, build.xml, external.properties, resources, resources/log4j.properties, src, src/uk, src/uk/me, src/uk/me/parabola, src/uk/me/parabola/mkosmgmap, src/uk/me/parabola/mkosmgmap/img, src/uk/me/parabola/mkosmgmap/img/FAT.java, src/uk/me/parabola/mkosmgmap/img/FileSystem.java, src/uk/me/parabola/mkosmgmap/img/ImgFile.java, src/uk/me/parabola/mkosmgmap/img/ImgHeader.java, src/uk/me/parabola/mkosmgmap/img/PartitionTable.java, src/uk/me/parabola/mkosmgmap/osm: Initial checkin. Mostly empty files. Structure set up and ant file works. * branches, releases, tags, .: Created mkosmgmap project mkgmap-r1067/LICENCE0000644000076400007640000004310510542500276013146 0ustar stevesteve GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. mkgmap-r1067/src/0000755000076400007640000000000011216306457012751 5ustar stevestevemkgmap-r1067/src/uk/0000755000076400007640000000000011216306457013370 5ustar stevestevemkgmap-r1067/src/uk/me/0000755000076400007640000000000011216306457013771 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/0000755000076400007640000000000011216306457015552 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/tdbfmt/0000755000076400007640000000000011216306457017032 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/tdbfmt/TBlock.java0000644000076400007640000000256311033117613021050 0ustar stevesteve/* * Copyright (C) 2008 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Jun-2008 */ package uk.me.parabola.tdbfmt; import java.io.IOException; import uk.me.parabola.io.StructuredOutputStream; /** * @author Steve Ratcliffe */ public class TBlock { private long sum; public void write(Block block) throws IOException { StructuredOutputStream os = block.getOutputStream(); // If you change A,B,C or D the maps // will not load, you can change the rest without easily visible // problems although I suppose they must do something. // // A,B,C,D is a standard crc32 sum of the rest of the file. // (Andrzej Popowsk) os.write2(0); os.write((int) (sum >> 24)); // A os.write3(0); os.write3(0); os.write((int) (sum >> 16)); // B os.write2(0); os.write((int) (sum >> 8)); // C os.write4(0); os.write((int) sum); // D os.write2(0); } public void setSum(long sum) { this.sum = sum; } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/TdbFile.java0000644000076400007640000001477611154317465021227 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.zip.CRC32; import java.util.zip.CheckedOutputStream; import uk.me.parabola.imgfmt.app.Area; import uk.me.parabola.io.EndOfFileException; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.log.Logger; /** * The TDB file. See the package documentation for more details. * * @author Steve Ratcliffe */ public class TdbFile { private static final Logger log = Logger.getLogger(TdbFile.class); public static final int TDB_V3 = 300; public static final int TDB_V407 = 407; private static final int BLOCK_OVERVIEW = 0x42; private static final int BLOCK_HEADER = 0x50; private static final int BLOCK_COPYRIGHT = 0x44; private static final int BLOCK_DETAIL = 0x4c; private static final int BLOCK_R = 0x52; private static final int BLOCK_T = 0x54; // The version number of the TDB format private int tdbVersion; // The blocks that go to make up the file. private HeaderBlock headerBlock; private CopyrightBlock copyrightBlock = new CopyrightBlock(); private OverviewMapBlock overviewMapBlock; private final List detailBlocks = new ArrayList(); private final RBlock rblock = new RBlock(); private final TBlock tblock = new TBlock(); private String overviewDescription; public TdbFile() { } public TdbFile(int tdbVersion) { this.tdbVersion = tdbVersion; } /** * Read in a TDB file from the disk. * * @param name The file name to load. * @return A TdbFile instance. * @throws IOException For problems reading the file. */ public static TdbFile read(String name) throws IOException { TdbFile tdb = new TdbFile(); InputStream is = new BufferedInputStream(new FileInputStream(name)); try { StructuredInputStream ds = new StructuredInputStream(is); tdb.load(ds); } finally { is.close(); } return tdb; } public void setProductInfo(int familyId, int productId, short productVersion, String seriesName, String familyName, String overviewDescription) { headerBlock = new HeaderBlock(tdbVersion); headerBlock.setFamilyId((short) familyId); headerBlock.setProductId((short) productId); headerBlock.setProductVersion(productVersion); headerBlock.setSeriesName(seriesName); headerBlock.setFamilyName(familyName); this.overviewDescription = overviewDescription; } /** * Add a copyright segment to the file. * @param msg The message to add. */ public void addCopyright(String msg) { CopyrightSegment seg = new CopyrightSegment(CopyrightSegment.CODE_COPYRIGHT_TEXT_STRING, 3, msg); copyrightBlock.addSegment(seg); } /** * Set the overview information. Basically the overall size of the map * set. * @param name The overview map name. * @param bounds The bounds for the map. */ public void setOverview(String name, Area bounds) { overviewMapBlock = new OverviewMapBlock(); overviewMapBlock.setArea(bounds); overviewMapBlock.setMapName(name); overviewMapBlock.setDescription(overviewDescription); } /** * Add a detail block. This describes and names one of the maps in the * map set. * @param detail The detail to add. */ public void addDetail(DetailMapBlock detail) { detailBlocks.add(detail); } public void write(String name) throws IOException { CheckedOutputStream stream = new CheckedOutputStream( new BufferedOutputStream(new FileOutputStream(name)), new CRC32()); if (headerBlock == null || overviewMapBlock == null) throw new IOException("Attempting to write file without being fully set up"); try { Block block = new Block(BLOCK_HEADER); headerBlock.write(block); block.write(stream); block = new Block(BLOCK_COPYRIGHT); copyrightBlock.write(block); block.write(stream); if (tdbVersion >= TDB_V407) { block = new Block(BLOCK_R); rblock.write(block); block.write(stream); } block = new Block(BLOCK_OVERVIEW); overviewMapBlock.write(block); block.write(stream); for (DetailMapBlock detail : detailBlocks) { block = new Block(BLOCK_DETAIL); detail.write(block); block.write(stream); } if (tdbVersion >= TDB_V407) { tblock.setSum(stream.getChecksum().getValue()); block = new Block(BLOCK_T); tblock.write(block); block.write(stream); } } finally { stream.close(); } } /** * Load from the given file name. * * @param ds The stream to read from. * @throws IOException For problems reading the file. */ private void load(StructuredInputStream ds) throws IOException { while (!ds.testEof()) { Block block = readBlock(ds); switch (block.getBlockId()) { case BLOCK_HEADER: headerBlock = new HeaderBlock(block); log.info("header block seen", headerBlock); break; case BLOCK_COPYRIGHT: log.info("copyright block"); copyrightBlock = new CopyrightBlock(block); break; case BLOCK_OVERVIEW: overviewMapBlock = new OverviewMapBlock(block); log.info("overview block", overviewMapBlock); break; case BLOCK_DETAIL: DetailMapBlock db = new DetailMapBlock(block); log.info("detail block", db); detailBlocks.add(db); break; default: log.warn("Unknown block in tdb file"); break; } } } /** * The file is divided into blocks. This reads a single block. * * @param is The input stream. * @return A block from the file. * @throws IOException For problems reading the file. */ private Block readBlock(StructuredInputStream is) throws IOException { int blockType = is.read(); if (blockType == -1) throw new EndOfFileException(); int blockLength = is.read2(); byte[] body = new byte[blockLength]; int n = is.read(body); if (n < 0) throw new IOException("failed to read block"); return new Block(blockType, body); } public int getTdbVersion() { return headerBlock.getTdbVersion(); } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/TestTdb.java0000644000076400007640000000172310713720376021252 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import uk.me.parabola.log.Logger; import java.io.IOException; /** * @author Steve Ratcliffe */ public class TestTdb { private static final Logger log = Logger.getLogger(TestTdb.class); public static void main(String[] args) throws IOException { Logger.resetLogging("localtest/log/log.all"); TdbFile tdb = TdbFile.read(args[0]); log.debug(tdb); //tdb.write("test.tdb"); } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/Block.java0000644000076400007640000000613210763340724020732 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import uk.me.parabola.log.Logger; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.io.StructuredOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; /** * A block within the tdb file. Really just a type and the contents. * * @author Steve Ratcliffe */ class Block { private static final Logger log = Logger.getLogger(Block.class); private final int blockId; private int blockLength; private byte[] body; private StructuredInputStream istream; private ByteArrayOutputStream arrayBody; private StructuredOutputStream ostream; /** * Create a block that is going to be written to. * @param blockId The id for this block. */ Block(int blockId) { this.blockId = blockId; } /** * Create a block from data that is read in from a file. * @param type The block type. * @param body The raw bytes in the block. */ Block(int type, byte[] body) { blockId = type; this.body = body; this.blockLength = body.length; ByteArrayInputStream stream = new ByteArrayInputStream(body); this.istream = new StructuredInputStream(stream); } public int getBlockId() { return blockId; } /** * Get the raw bytes for this block. The source depends on if this block * was constructed from file data, or is being created from program calls * so that it can be written. * * @return A byte array of the raw bytes representing this block. */ byte[] getBody() { if (body == null && arrayBody != null) { byte[] bytes = arrayBody.toByteArray(); blockLength = bytes.length - 3; // Fill in the length in the space that we left earlier. bytes[1] = (byte) (blockLength & 0xff); bytes[2] = (byte) ((blockLength >> 8) & 0xff); return bytes; } return body; } /** * Get a stream for the body of this block. * * @return A structured stream that can be used to read the body of this * block. */ public StructuredInputStream getInputStream() { arrayBody = null; return this.istream; } public StructuredOutputStream getOutputStream() { if (ostream == null) { arrayBody = new ByteArrayOutputStream(); body = null; ostream = new StructuredOutputStream(arrayBody); try { ostream.write(blockId); ostream.write2(0); // This will be filled in later. } catch (IOException e) { log.warn("failed writing to array"); } } return ostream; } public void write(OutputStream stream) throws IOException { byte[] b = getBody(); if (b != null) stream.write(b); } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/RBlock.java0000644000076400007640000000167611110054726021053 0ustar stevesteve/* * Copyright (C) 2008 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Jun-2008 */ package uk.me.parabola.tdbfmt; import java.io.IOException; import uk.me.parabola.io.StructuredOutputStream; /** * @author Steve Ratcliffe */ public class RBlock { private final String previewDescription = "Test preview map"; public void write(Block block) throws IOException { StructuredOutputStream os = block.getOutputStream(); os.write(0xc3); os.writeString(previewDescription); } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/HeaderBlock.java0000644000076400007640000000650311146630304022035 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import java.io.IOException; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.io.StructuredOutputStream; /** * The header block. Identifies the particular map set. * * @author Steve Ratcliffe */ class HeaderBlock { /** The map family. */ private short familyId; /** A unique number associated with the map product */ private short productId; /** The version of TDB */ private final int tdbVersion; /** The series name is an overall name eg 'US Topo' */ private String seriesName; /** The version number of the map product */ private short productVersion; /** * Identifies a map within the series * @see #seriesName */ private String familyName; HeaderBlock(int tdbVersion) { this.tdbVersion = tdbVersion; } HeaderBlock(Block block) throws IOException { StructuredInputStream ds = block.getInputStream(); productId = (short) ds.read2(); familyId = (short) ds.read2(); tdbVersion = ds.read2(); seriesName = ds.readString(); productVersion = (short) ds.read2(); familyName = ds.readString(); } public void write(Block block) throws IOException { StructuredOutputStream os = block.getOutputStream(); os.write2(productId); os.write2(familyId); os.write2(tdbVersion); os.writeString(seriesName); os.write2(productVersion); os.writeString(familyName); if (tdbVersion >= TdbFile.TDB_V407) { // Unknown purpose os.write(0); os.write(0x12); // lowest map level os.write(1); os.write(1); os.write(1); os.write4(0); os.write(0); os.write(0x18); // highest routable? 19 no, 21 ok os.write4(0); os.write4(0); os.write4(0); os.write4(0); os.write3(0); os.write4(1252); os.write4(10000); os.write(1); os.write2(0); } } // good //os.write(0); //os.write(0x12); //os.write(1); //os.write(1); //os.write(1); //os.write4(0); //os.write(0); //os.write(0x15); //os.write4(0); //os.write4(0); //os.write4(0); //os.write4(0); //os.write3(0); //os.write4(1252); //os.write4(10000); //os.write(1); //os.write(0); //os.write(0); public String toString() { return "TDB header: " + productId + " version=" + tdbVersion + ", series:" + seriesName + ", family:" + familyName + ", ver=" + productVersion ; } public void setProductId(short productId) { this.productId = productId; } public void setSeriesName(String seriesName) { this.seriesName = seriesName; } public void setFamilyName(String familyName) { this.familyName = familyName; } public void setProductVersion(short productVersion) { this.productVersion = productVersion; } public void setFamilyId(short familyId) { this.familyId = familyId; } public int getTdbVersion() { return tdbVersion; } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/package.html0000644000076400007640000000056211154317465021320 0ustar stevesteve

The TDB file format

The TDB file contains summary information about individual IMG files that make up a map set. It is usual for a map to be broken down into a set of tiles and the TDB file gives an overview of how they all fit together.

Acknowledgments

Based on the document Garmin TDB File Format by John Mechalas

mkgmap-r1067/src/uk/me/parabola/tdbfmt/CopyrightBlock.java0000644000076400007640000000336510763340724022630 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import uk.me.parabola.log.Logger; import uk.me.parabola.io.StructuredInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.HashSet; /** * A copyright block consists of a number of copyright segments. * * @author Steve Ratcliffe */ class CopyrightBlock { private static final Logger log = Logger.getLogger(CopyrightBlock.class); private final List segments = new ArrayList(); private final Set copySet = new HashSet(); CopyrightBlock() { } CopyrightBlock(Block block) throws IOException { StructuredInputStream ds = block.getInputStream(); while (!ds.testEof()) { CopyrightSegment segment = new CopyrightSegment(ds); log.info("segment: " + segment); segments.add(segment); } } public void write(Block block) throws IOException { for (CopyrightSegment seg : segments) { seg.write(block); } } /** * Add a copyright segment. We only add unique ones. * @param seg The copyright segment to add. */ public void addSegment(CopyrightSegment seg) { if (copySet.add(seg)) segments.add(seg); } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/DetailMapBlock.java0000644000076400007640000000670711031445030022504 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.io.StructuredOutputStream; import java.io.IOException; /** * Details of a single .img file that is part of the map set. There will be * one of these for each .img file. * * @author Steve Ratcliffe */ public class DetailMapBlock extends OverviewMapBlock { private int tdbVersion; // Sizes of the regions. It is possible that rgn and tre are reversed? private int rgnDataSize; private int treDataSize; private int lblDataSize; private int netDataSize; private int nodDataSize; public DetailMapBlock(int tdbVersion) { assert tdbVersion > 0; this.tdbVersion = tdbVersion; } /** * Initialise this block from the raw block given. * @param block The raw block read from the file. * @throws IOException For io problems. */ public DetailMapBlock(Block block) throws IOException { super(block); StructuredInputStream ds = block.getInputStream(); // First there are a couple of fields that we ignore. int junk = ds.read2(); assert junk == 4; junk = ds.read2(); assert junk == 3; // Sizes of the data rgnDataSize = ds.read4(); treDataSize = ds.read4(); lblDataSize = ds.read4(); // Another ignored field junk = ds.read(); assert junk == 1; } /** * Write into the given block. * * @param block The block that will have been initialised to be a detail * block. * @throws IOException Problems writing, probably can't really happen as * we use an array backed stream. */ public void write(Block block) throws IOException { super.write(block); StructuredOutputStream os = block.getOutputStream(); int n = 3; if (tdbVersion >= TdbFile.TDB_V407) { if (netDataSize > 0) n++; if (nodDataSize > 0) n++; } os.write2(n+1); os.write2(n); os.write4(treDataSize); os.write4(rgnDataSize); os.write4(lblDataSize); if (tdbVersion >= TdbFile.TDB_V407) { if (n > 3) os.write4(netDataSize); if (n > 4) os.write4(nodDataSize); //01 c3 00 ff os.write4(0xff00c301); os.write(0); os.write(0); os.write(0); String mn = getMapName(); os.writeString(mn + ".TRE"); os.writeString(mn + ".RGN"); os.writeString(mn + ".LBL"); if (n > 3) os.writeString(mn + ".NET"); if (n > 4) os.writeString(mn + ".NOD"); } else { os.write(1); } } public void setRgnDataSize(int rgnDataSize) { this.rgnDataSize = rgnDataSize; } public void setTreDataSize(int treDataSize) { this.treDataSize = treDataSize; } public void setLblDataSize(int lblDataSize) { this.lblDataSize = lblDataSize; } public void setNetDataSize(int netDataSize) { this.netDataSize = netDataSize; } public void setNodDataSize(int nodDataSize) { this.nodDataSize = nodDataSize; } public String toString() { return super.toString() + ", rgn size=" + rgnDataSize + ", tre size=" + treDataSize + ", lbl size" + lblDataSize ; } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/OverviewMapBlock.java0000644000076400007640000000620611112275126023111 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import java.io.IOException; import uk.me.parabola.imgfmt.app.Area; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.io.StructuredOutputStream; /** * The overview map provides a low-detail image for the detailed maps. It * allows you to see what areas the detail maps cover so they can be selected * in programs such as QLandkarte and Garmin's MapSource. * * In addition to a low detail map, the overview map contains a number of type * 0x4a polygons. These definition areas a labeled after and correspond to * the detail map img files. * * The detail maps contain a background polygon (type 0x4b) that matches the * definition area in the overview map. * * @author Steve Ratcliffe */ public class OverviewMapBlock { private int mapNumber; private String mapName; private int parentMapNumber; private String description; private int maxLat; private int maxLong; private int minLat; private int minLong; public OverviewMapBlock() { description = "overview map"; } public OverviewMapBlock(Block block) throws IOException { StructuredInputStream ds = block.getInputStream(); mapNumber = ds.read4(); parentMapNumber = ds.read4(); maxLat = ds.read4(); maxLong = ds.read4(); minLat = ds.read4(); minLong = ds.read4(); description = ds.readString(); } public void write(Block block) throws IOException { StructuredOutputStream os = block.getOutputStream(); os.write4(mapNumber); os.write4(parentMapNumber); os.write4(maxLat); os.write4(maxLong); os.write4(minLat); os.write4(minLong); os.writeString(description); } public String toString() { return "Overview: " + mapNumber + ", parent=" + parentMapNumber + " covers " + '(' + toDegrees(minLat) + ',' + toDegrees(minLong) + ')' + '(' + toDegrees(maxLat) + ',' + toDegrees(maxLong) + ')' + " : " + description ; } private double toDegrees(int tdbunits) { return (double) tdbunits * 360 / Math.pow(2, 32); } public void setArea(Area bounds) { minLat = bounds.getMinLat() << 8; minLong = bounds.getMinLong() << 8; maxLat = bounds.getMaxLat() << 8; maxLong = bounds.getMaxLong() << 8; } public void setDescription(String description) { this.description = description; } public void setMapName(String mapName) { this.mapName = mapName; try { this.mapNumber = Integer.parseInt(mapName); } catch (NumberFormatException e) { this.mapNumber = 0; } } protected String getMapName() { return mapName; } public void setParentMapNumber(int parentMapNumber) { this.parentMapNumber = parentMapNumber; } } mkgmap-r1067/src/uk/me/parabola/tdbfmt/CopyrightSegment.java0000644000076400007640000000571111114073674023173 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 23-Sep-2007 */ package uk.me.parabola.tdbfmt; import uk.me.parabola.io.StructuredInputStream; import uk.me.parabola.io.StructuredOutputStream; import java.io.IOException; /** * One copyright that is within the copyright block. * * @author Steve Ratcliffe */ class CopyrightSegment { /** * Source information text string. Describes what data sources were used * in generating the map. */ public static final int CODE_SOURCE_INFORMATION = 0x00; /** Copyright information from the map manufacturer. */ public static final int CODE_COPYRIGHT_TEXT_STRING = 0x06; /** * A filename that contains a BMP image to be printed along with * the map. */ public static final int CODE_COPYRIGHT_BITMAP_REFERENCE = 0x07; /** * A code that shows what kind of copyright information is * contaied in this segment. * The field {@link #extraProperties} can be used too as extra information. */ private final byte copyrightCode; private final byte whereCode; private final short extraProperties; private final String copyright; CopyrightSegment(StructuredInputStream ds) throws IOException { copyrightCode = (byte) ds.read(); whereCode = (byte) ds.read(); extraProperties = (short) ds.read2(); copyright = ds.readString(); } CopyrightSegment(int code, int where, String msg) { this.copyrightCode = (byte) code; this.whereCode = (byte) where; this.copyright = msg; this.extraProperties = 0; } public void write(Block block) throws IOException { StructuredOutputStream os = block.getOutputStream(); os.write(copyrightCode); os.write(whereCode); os.write2(extraProperties); os.writeString(copyright); } public String toString() { return "Copyright: " + copyrightCode + ", where=" + whereCode + ", extra=" + extraProperties + ": " + copyright ; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CopyrightSegment that = (CopyrightSegment) o; if (copyrightCode != that.copyrightCode) return false; if (extraProperties != that.extraProperties) return false; if (whereCode != that.whereCode) return false; if (!copyright.equals(that.copyright)) return false; return true; } public int hashCode() { int result = (int) copyrightCode; result = 31 * result + (int) whereCode; result = 31 * result + (int) extraProperties; result = 31 * result + copyright.hashCode(); return result; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/0000755000076400007640000000000011216306457017035 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/FileSystemParam.java0000644000076400007640000000307210711457454022752 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 02-Dec-2006 */ package uk.me.parabola.imgfmt; /** * Small class to hold all kinds of filesystem parameters. If a field * is not set then it is not used. * * @author Steve Ratcliffe */ public class FileSystemParam { private String mapDescription = "Open Street Map"; private int blockSize = 512; private int directoryStartBlock = 2; private int reservedDirectoryBlocks = 202; public String getMapDescription() { return mapDescription; } public void setMapDescription(String mapDescription) { this.mapDescription = mapDescription; } public int getBlockSize() { return blockSize; } public void setBlockSize(int blockSize) { this.blockSize = blockSize; } public int getDirectoryStartBlock() { return directoryStartBlock; } public void setDirectoryStartBlock(int directoryStartBlock) { this.directoryStartBlock = directoryStartBlock; } public int getReservedDirectoryBlocks() { return reservedDirectoryBlocks; } public void setReservedDirectoryBlocks(int blocks) { this.reservedDirectoryBlocks = blocks; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/fs/0000755000076400007640000000000011216306457017445 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/fs/FileSystem.java0000644000076400007640000000474610727772653022422 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 26-Nov-2006 */ package uk.me.parabola.imgfmt.fs; import uk.me.parabola.imgfmt.FileExistsException; import uk.me.parabola.imgfmt.FileSystemParam; import java.util.List; import java.io.FileNotFoundException; import java.io.IOException; /** * File system operations. * * @author Steve Ratcliffe */ public interface FileSystem { /** * Create a new file it must not allready exist. * @param name The file name. * @return A directory entry for the new file. * @throws FileExistsException If the file already exists. */ public ImgChannel create(String name) throws FileExistsException; /** * Open a file. The returned file object can be used to read and write the * underlying file. * * @param name The file name to open. * @param mode Either "r" for read access, "w" for write access or "rw" * for both read and write. * @return A file descriptor. * @throws FileNotFoundException When the file does not exist. */ public ImgChannel open(String name, String mode) throws FileNotFoundException; /** * Lookup the file and return a directory entry for it. * * @param name The filename to look up. * @return A directory entry. * @throws IOException If an error occurs reading the directory. */ public DirectoryEntry lookup(String name) throws IOException; /** * List all the files in the directory. * @return A List of directory entries. */ public List list() ; /** * Get the filesystem / archive parameters. Things that are stored in * the header. * * @return The filesystem parameters. */ public FileSystemParam fsparam(); /** * Sync with the underlying file. All unwritten data is written out to * the underlying file. * @throws IOException If an error occurs during the write. */ public void sync() throws IOException; /** * Close the filesystem. Any saved data is flushed out. It is better * to explicitly sync the data out first, to be sure that it has worked. */ void close(); } mkgmap-r1067/src/uk/me/parabola/imgfmt/fs/DirectoryEntry.java0000644000076400007640000000261510727772653023315 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 02-Dec-2006 */ package uk.me.parabola.imgfmt.fs; /** * Interface used for directory entries used to represent files. * A directory entry has the file name, its extension (its a 8+3 filename) * and the size of the file. * * @author Steve Ratcliffe */ public interface DirectoryEntry { /** * Get the file name. * @return The file name. */ public String getName(); /** * Get the file extension. * @return The file extension. */ public String getExt(); /** * Get the full name. That is name + extension. * * @return The full name as NAME.EXT */ public String getFullName(); /** * Get the file size. * @return The size of the file in bytes. */ public int getSize(); /** * If this is a special 'hidden' file. True for the all-spaces 'file'. * * @return True if this is not a regular file. */ public boolean isSpecial(); } mkgmap-r1067/src/uk/me/parabola/imgfmt/fs/ImgChannel.java0000644000076400007640000000242710711457454022325 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 02-Dec-2006 */ package uk.me.parabola.imgfmt.fs; import java.nio.channels.ByteChannel; /** * An extension of ByteChannel that allows us to know the position. It may * evolve to have several of the methods of the FileChannel class and plays * a similar role. * * @author Steve Ratcliffe */ public interface ImgChannel extends ByteChannel { /** * Get the file position. Note that this is a logical position relative * to the begining of the file (the file within the .img file, not the * begining of the .img file itself). * * @return The offset in bytes from the beginning of the file. */ public long position(); /** * Set the position within the file. * * @param pos The position to set. */ public void position(long pos); } mkgmap-r1067/src/uk/me/parabola/imgfmt/fs/package.html0000644000076400007640000000057110637204532021726 0ustar stevesteve

Interfaces for accessing the filesystem

These are the way that application code should access the filesystem parts of the code.

The main interface is {@link uk.me.parabola.imgfmt.fs.FileSystem} which contains all the operations that can be performed on the system.

See also

The Garmin img project mkgmap-r1067/src/uk/me/parabola/imgfmt/ReadFailedException.java0000644000076400007640000000253610766754612023556 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt; /** * @author Steve Ratcliffe */ public class ReadFailedException extends RuntimeException { /** * Constructs a new runtime exception with the specified detail message and * cause.

Note that the detail message associated with cause * is not automatically incorporated in this runtime exception's detail * message. * * @param message the detail message (which is saved for later retrieval by the * {@link #getMessage()} method). * @param cause the cause (which is saved for later retrieval by the {@link * #getCause()} method). (A null value is permitted, and indicates * that the cause is nonexistent or unknown.) * @since 1.4 */ public ReadFailedException(String message, Throwable cause) { super(message, cause); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/FileNotWritableException.java0000644000076400007640000000167711000461742024612 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 02-Sep-2007 */ package uk.me.parabola.imgfmt; import java.io.IOException; /** * If a file cannot be created, or written to, then this exception is thrown. * @author Steve Ratcliffe */ public class FileNotWritableException extends IOException { public FileNotWritableException(String s, Exception e) { // super class does not have the constructor that takes an exception super(s + ' ' + e.getMessage()); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/Utils.java0000644000076400007640000001143111210173232020763 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 */ package uk.me.parabola.imgfmt; import java.io.Closeable; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Calendar; import java.util.Date; /** * Some miscellaneous functions that are used within the .img code. * * @author Steve Ratcliffe */ public class Utils { /** * Routine to convert a string to bytes and pad with a character up * to a given length. * Only to be used for strings that are expressable in latin1. * * @param s The original string. * @param len The length to pad to. * @param pad The byte used to pad. * @return An array created from the string. */ public static byte[] toBytes(String s, int len, byte pad) { if (s == null) throw new IllegalArgumentException("null string provided"); byte[] out = new byte[len]; for (int i = 0; i < len; i++) { if (i > s.length()) { out[i] = pad; } else { out[i] = (byte) s.charAt(i); } } return out; } public static byte[] toBytes(String s) { return toBytes(s, s.length(), (byte) 0); } /** * Convert from bytes to a string. Only to be used when the character set * is ascii or latin1. * * @param buf A byte buffer to get the bytes from. Should be ascii or latin1. * @param off The offset into buf. * @param len The length to get. * @return A string. */ public static String bytesToString(ByteBuffer buf, int off, int len) { if (buf == null) throw new IllegalArgumentException("null byte buffer provided"); byte[] bbuf = new byte[len]; buf.position(off); buf.get(bbuf); char[] cbuf = new char[len]; for (int i = 0; i < bbuf.length; i++) { cbuf[i] = (char) bbuf[i]; } return new String(cbuf); } /** * Set the creation date. Note that the year is encoded specially. * * @param buf The buffer to write into. It must have been properly positioned * beforehand. * @param date The date to set. */ public static void setCreationTime(ByteBuffer buf, Date date) { Calendar cal = Calendar.getInstance(); Date d = date; if (d == null) d = new Date(); cal.setTime(d); buf.putChar((char) cal.get(Calendar.YEAR)); buf.put((byte) (cal.get(Calendar.MONTH))); buf.put((byte) cal.get(Calendar.DAY_OF_MONTH)); buf.put((byte) cal.get(Calendar.HOUR)); buf.put((byte) cal.get(Calendar.MINUTE)); buf.put((byte) cal.get(Calendar.SECOND)); } /** * A map unit is an integer value that is 1/(2^24) degrees of latitude or * longitude. * * @param l The lat or long as decimal degrees. * @return An integer value in map units. */ public static int toMapUnit(double l) { double DELTA = 360.0D / (1 << 24) / 2; //Correct rounding if (l > 0) return (int) ((l + DELTA) * (1 << 24)/360); else return (int) ((l - DELTA) * (1 << 24)/360); } /** * Convert a date into the in-file representation of a date. * * @param date The date. * @return A byte stream in .img format. */ public static byte[] makeCreationTime(Date date) { Calendar cal = Calendar.getInstance(); Date d = date; if (d == null) d = new Date(); cal.setTime(d); byte[] ret = new byte[7]; ByteBuffer buf = ByteBuffer.wrap(ret); buf.order(ByteOrder.LITTLE_ENDIAN); buf.putChar((char) (cal.get(Calendar.YEAR) - 1900)); buf.put((byte) (cal.get(Calendar.MONTH))); buf.put((byte) cal.get(Calendar.DAY_OF_MONTH)); buf.put((byte) cal.get(Calendar.HOUR)); buf.put((byte) cal.get(Calendar.MINUTE)); buf.put((byte) cal.get(Calendar.SECOND)); return ret; } /** * Make a date from the garmin representation. * @param date The bytes representing the date. * @return A java date. */ public static Date makeCreationTime(byte[] date) { Calendar cal = Calendar.getInstance(); int y = ((date[1] & 0xff) << 8) + (date[0] & 0xff); cal.set(y, date[2], date[3], date[4], date[5], date[6]); return cal.getTime(); } /** * Convert an angle in map units to degrees. */ public static double toDegrees(int val) { return (double) val * (360.0 / (1 << 24)); } /** * Convert an angle in map units to radians. */ public static double toRadians(int mapunits) { return toDegrees(mapunits) * (Math.PI / 180); } public static void closeFile(Closeable f) { if (f != null) { try { f.close(); } catch (IOException e) { e.printStackTrace(); } } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/0000755000076400007640000000000011216306457017653 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/sys/HeaderDirent.java0000644000076400007640000000405110711457454023057 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 27-Oct-2007 */ package uk.me.parabola.imgfmt.sys; /** * This is a special Dirent class for the header. It makes it easier to bootstrap * the directory by having a special implementation that starts up by knowing * that the blocks in the header start from 0. * * @author Steve Ratcliffe */ class HeaderDirent extends Dirent { HeaderDirent(String name, BlockManager blockManager) { super(name, blockManager); } /** * Converts from a logical block to a physical block. This is a special * version that returns the logical block number when the Dirent is not * set up. This allows us to bootstrap the reading of the header blocks. * The header blocks always logical and physical blocks the same. * * @param lblock The logical block in the file. * @return The corresponding physical block in the filesystem. */ public int getPhysicalBlock(int lblock) { if (isInitialized()) { log.debug("gpb (ok)"); return super.getPhysicalBlock(lblock); } else { log.debug("gpb (not setup)"); return lblock; } } /** * Get the file size. The file appears large until the first blocks are * read in and then it will take on its actual size. * * @return The size of the file in bytes. */ public int getSize() { if (isInitialized()) return super.getSize(); else return getBlockManager().getBlockSize() * 32; } /** * Always returns true as this is only used for the special header * directory entry. * * @return Always returns true. */ public boolean isSpecial() { return true; } }mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/FileNode.java0000644000076400007640000002116311105666203022201 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 */ package uk.me.parabola.imgfmt.sys; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.ClosedByInterruptException; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.nio.channels.NonReadableChannelException; import java.nio.channels.NonWritableChannelException; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * The internal representation of a file in the file system. In use it * should only be referred to by the {@link ImgChannel} interface. * * @author Steve Ratcliffe */ public class FileNode implements ImgChannel { private static final Logger log = Logger.getLogger(FileNode.class); private boolean open; private boolean writeable; private boolean readable; private final FileChannel file; private final BlockManager blockManager; private final Dirent dirent; // The position in this file private long position; /** * Creates a new file in the file system. You can treat this just like * a regular file and write or read from it. * Operations to two different files may not be interleaved although * it may be possible to implement this. * * @param file The handle to the underlying file. * @param dir The directory entry associated with this file. * @param mode The mode "rw" for read and write etc. */ public FileNode(FileChannel file, Dirent dir, String mode) { this.file = file; this.dirent = dir; if (mode.indexOf('r') >= 0) readable = true; if (mode.indexOf('w') >= 0) writeable = true; if (!(readable || writeable)) throw new IllegalArgumentException("File must be readable or writeable"); blockManager = dir.getBlockManager(); if (blockManager == null) throw new IllegalArgumentException("no file system supplied"); open = true; } /** * Closes this channel. *

*

After a channel is closed, any further attempt to invoke I/O * operations upon it will cause a {@link ClosedChannelException} to be * thrown. *

*

If this channel is already closed then invoking this method has no * effect. *

*

This method may be invoked at any time. If some other thread has * already invoked it, however, then another invocation will block until * the first invocation is complete, after which it will return without * effect.

* * @throws IOException If an I/O error occurs */ public void close() throws IOException { if (!open) return; sync(); open = false; readable = false; writeable = false; } /** * Tells whether or not this channel is open.

* * @return true if, and only if, this channel is open */ public boolean isOpen() { return open; } /** * Reads a sequence of bytes from this channel into the given buffer. * * @param dst The buffer into which bytes are to be transferred * * @return The number of bytes read, possibly zero, or -1 if the * channel has reached end-of-stream * * @throws NonReadableChannelException If this channel was not opened for reading * @throws ClosedChannelException If this channel is closed * @throws AsynchronousCloseException If another thread closes this channel * while the read operation is in progress * @throws ClosedByInterruptException If another thread interrupts the * current thread while the read operation is in progress, thereby closing * the channel and setting the current thread's interrupt status * @throws IOException If some other I/O error occurs */ public int read(ByteBuffer dst) throws IOException { if (!open) throw new ClosedChannelException(); if (!readable) throw new NonReadableChannelException(); int blockSize = blockManager.getBlockSize(); long size = dst.remaining(); long fileSize = dirent.getSize(); if (position >= fileSize) return -1; size = Math.min(size, fileSize - position); int totalRead = 0; while (size > 0) { // Tet the logical block number, as we see it in our file. int lblock = (int) (position / blockSize); // Get the physical block number, the actual block number in // the underlying file. int pblock = dirent.getPhysicalBlock(lblock); if (pblock == 0xffff) { // We are at the end of the file. log.debug("at eof"); break; } // Position the underlying file int off = (int) (position - lblock*blockSize); file.position((long) pblock * blockSize + off); int n = (int) size; if (n > blockSize) n = blockSize; if (off != 0) n = Math.min(n, blockSize - off); dst.limit(dst.position() + n); int nr = file.read(dst); if (nr == -1) return -1; if (nr == 0) throw new IOException("Read nothing"); // Update the file positions size -= nr; position += nr; totalRead += nr; } log.debug("read ret", totalRead); return totalRead; } /** * Writes a sequence of bytes to this channel from the given buffer. *

*

An attempt is made to write up to r bytes to the channel, * where r is the number of bytes remaining in the buffer, that is, * dst.remaining(), at the moment this method is invoked. *

The logical block has to be converted to a physical block in the * underlying file. * * @param src The buffer from which bytes are to be retrieved * @return The number of bytes written, possibly zero * @throws NonWritableChannelException * If this channel was not opened for writing * @throws ClosedChannelException * If this channel is closed * @throws IOException If some other I/O error occurs */ public int write(ByteBuffer src) throws IOException { if (!open) throw new ClosedChannelException(); int blockSize = blockManager.getBlockSize(); // Get the size of this write int size = src.remaining(); // Loop over each block, this is to support the case (which we may // not implement) of non-contiguous blocks. int totalWritten = 0; while (size > 0) { // Get the logical block, ie the block as we see it in our file. int lblock = (int) (position/blockSize); // First need to allocate enough blocks for this write. First check // if the block exists already int pblock = dirent.getPhysicalBlock(lblock); log.debug("lblock / pblock", lblock, '/', pblock); if (pblock == 0xffff) { log.debug("allocating new block"); pblock = blockManager.allocate(); dirent.addBlock(pblock); } // Position the underlying file, so that it is in the correct place. int off = (int) (position - lblock*blockSize); file.position((long) pblock * blockSize + off); int n = size; if (n > blockSize) n = blockSize; if (off != 0) n = Math.min(n, blockSize - off); src.limit(src.position() + n); // Write to the underlying file. int nw = file.write(src); if (nw == 0) throw new IOException("Wrote nothing"); // Update the file positions size -= nw; position += nw; totalWritten += nw; // Update file size. if (position > dirent.getSize()) dirent.setSize((int) position); } return totalWritten; } public long position() { return position; } public void position(long pos) { int blockSize = blockManager.getBlockSize(); while (pos > position) { long lblock = position / blockSize; int pblock = dirent.getPhysicalBlock((int) lblock); if (pblock == 0xffff) { if (writeable) { log.debug("setting position allocating new block", lblock); pblock = blockManager.allocate(); dirent.addBlock(pblock); } } position = (lblock+1) * blockSize; } this.position = pos; } /** * Write out any unsaved data to disk. * * @throws IOException If there is an error writing to disk. */ private void sync() throws IOException { if (!writeable) return; // Ensure that a complete block is written out. int bs = blockManager.getBlockSize(); long rem = bs - (file.position() % bs); ByteBuffer buf = ByteBuffer.allocate(blockManager.getBlockSize()); // Complete any partial block. for (int i = 0; i < rem; i++) buf.put((byte) 0); buf.flip(); file.write(buf); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/FileImgChannel.java0000644000076400007640000000463111114073674023326 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt.sys; import uk.me.parabola.imgfmt.ReadFailedException; import uk.me.parabola.imgfmt.fs.ImgChannel; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; /** * This is an implementation of ImgChannel that delegates to a regular channel. * It can therefore be used to read or write regular files on the file system. * * @author Steve Ratcliffe */ public class FileImgChannel implements ImgChannel { private final FileChannel channel; private long position; public FileImgChannel(String filename) { RandomAccessFile raf; try { raf = new RandomAccessFile(filename, "rw"); } catch (FileNotFoundException e) { throw new ReadFailedException("Couldnot open " + filename, e); } this.channel = raf.getChannel(); } public FileImgChannel(FileChannel channel) { this.channel = channel; } public int read(ByteBuffer dst) throws IOException { int n = channel.read(dst); if (n > 0) position += n; return n; } public boolean isOpen() { return channel.isOpen(); } public void close() throws IOException { channel.close(); } public int write(ByteBuffer src) throws IOException { int n = channel.write(src); position += n; return n; } /** * Get the file position. Note that this is a logical position relative to the * begining of the file (the file within the .img file, not the begining of the * .img file itself). * * @return The offset in bytes from the beginning of the file. */ public long position() { return position; } /** * Set the position within the file. * * @param pos The position to set. */ public void position(long pos) { try { channel.position(pos); position = pos; } catch (IOException e) { throw new ReadFailedException("Could not seek", e); } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/BlockTable.java0000644000076400007640000000713010711457454022524 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Feb-2007 */ package uk.me.parabola.imgfmt.sys; import uk.me.parabola.log.Logger; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Holds block numbers for a file. It is part of the directory. For a file * that needs more than one block several directory entries exist. Each of * these has the header with the file name etc. in it, but the first one has * extra flags and info. * *

What is important here is that only part of a full block is used to * hold block numbers. * *

The entries are 512 bytes regardless of the blocksize. * * @author Steve Ratcliffe */ class BlockTable { private static final Logger log = Logger.getLogger(BlockTable.class); // Offset of the block table in the directory entry block. private static final int BLOCKS_TABLE_START = 0x20; private static final int ENTRY_SIZE = 512; private static final int TABLE_SIZE = (ENTRY_SIZE - BLOCKS_TABLE_START)/2; //private final int tableSize; private int curroff; private final List blocks; private char[] currTable; BlockTable() { blocks = new ArrayList(200); } /** * Write out the specified table to the given buffer. * * @param buf The buffer to write to. * @param n The number of the block table to write out. */ public void writeTable(ByteBuffer buf, int n) { char[] cbuf = blocks.get(n); log.debug("block with length", cbuf.length); for (char c : cbuf) { buf.putChar(c); } } /** * Read a block table from the given buffer. The table is added to the * list. * @param buf The buffer to read from. */ public void readTable(ByteBuffer buf) { buf.position(BLOCKS_TABLE_START); buf.limit(ENTRY_SIZE); char[] cbuf = newTable(); for (int i = 0; i < cbuf.length; i++) { char c = buf.getChar(); cbuf[i] = c; } } /** * Add the given block number to this directory. * * @param n The block number to add. */ public void addBlock(int n) { char[] thisTable = currTable; if (curroff >= TABLE_SIZE || currTable == null) thisTable = newTable(); thisTable[curroff++] = (char) n; } /** * Given a logical block number, return the physical block number. * * @param lblock The logical block number, ie with respect to the file. * @return The physical block number in the file system. */ public int physFromLogical(int lblock) { int blockNum = lblock / TABLE_SIZE; int offset = lblock - blockNum * TABLE_SIZE; if (blockNum >= blocks.size()) return 0xffff; char[] cbuf = blocks.get(blockNum); return cbuf[offset]; } /** * Get the number of block tables. This is the number of blocks that * will be used in the on disk directory structure. * * @return The number of blocks tables. */ public int getNBlockTables() { return blocks.size(); } /** * Allocate a new block to hold more directory block numbers. * * @return Array for more numbers. */ private char[] newTable() { char[] table = new char[TABLE_SIZE]; Arrays.fill(table, (char) 0xffff); curroff = 0; blocks.add(table); currTable = table; return table; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/Directory.java0000644000076400007640000001356711116444437022476 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 26-Nov-2006 */ package uk.me.parabola.imgfmt.sys; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import uk.me.parabola.imgfmt.FileExistsException; import uk.me.parabola.imgfmt.Utils; import uk.me.parabola.imgfmt.fs.DirectoryEntry; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * The directory. There is only one directory and it contains the * filenames and block information. On disk each entry is a * multiple of the block size. * * @author Steve Ratcliffe */ class Directory { private static final Logger log = Logger.getLogger(Directory.class); //private final FileChannel file; private ImgChannel chan; private final BlockManager headerBlockManager; private long startPos; // The list of files themselves. private final Map entries = new LinkedHashMap(); Directory(BlockManager headerBlockManager) { this.headerBlockManager = headerBlockManager; } /** * Create a new file in the directory. * * @param name The file name. Must be 8+3 characters. * @param blockManager To allocate blocks for the created file entry. * @return The new directory entity. * @throws FileExistsException If the entry already * exists. */ Dirent create(String name, BlockManager blockManager) throws FileExistsException { // Check to see if it is already there. if (entries.get(name) != null) throw new FileExistsException("File " + name + " already exists"); Dirent ent; if (name.equals(ImgFS.DIRECTORY_FILE_NAME)) { ent = new HeaderDirent(name, blockManager); } else { ent = new Dirent(name, blockManager); } addEntry(ent); return ent; } /** * Initialise the directory for reading the file. The whole directory * is read in. * * @throws IOException If it cannot be read. */ void readInit() throws IOException { assert chan != null; ByteBuffer buf = ByteBuffer.allocate(512); buf.order(ByteOrder.LITTLE_ENDIAN); chan.position(startPos); Dirent current = null;while ((chan.read(buf)) > 0) { buf.flip(); int used = buf.get(Dirent.OFF_FILE_USED); if (used != 1) continue; String name = Utils.bytesToString(buf, Dirent.OFF_NAME, Dirent.MAX_FILE_LEN); String ext = Utils.bytesToString(buf, Dirent.OFF_EXT, Dirent.MAX_EXT_LEN); log.debug("readinit name", name, ext); int flag = buf.get(Dirent.OFF_FLAG); int part = buf.get(Dirent.OFF_FILE_PART) & 0xff; if (flag == 3 && current == null) { current = (Dirent) entries.get(ImgFS.DIRECTORY_FILE_NAME); current.initBlocks(buf); } else if (part == 0) { current = create(name + '.' + ext, headerBlockManager); current.initBlocks(buf); } else { assert current != null; current.initBlocks(buf); } buf.clear(); } } /** * Write out the directory to the file. The file should be correctly * positioned by the caller. * * @throws IOException If there is a problem writing out any * of the directory entries. */ public void sync() throws IOException { // The first entry can't really be written until the rest of the directory is // so we have to step through once to calculate the size and then again // to write it out. int blocks = 0; for (DirectoryEntry dir : entries.values()) { Dirent ent = (Dirent) dir; log.debug("ent size", ent.getSize()); int n = ent.numberHeaderBlocks(); blocks += n; } // Save the current position long dirPosition = chan.position(); int blockSize = headerBlockManager.getBlockSize(); int forHeader = (blocks + (blockSize - 1)) / blockSize; log.debug("header blocks needed", forHeader); // There is nothing really wrong with larger values (perhaps, I don't // know for sure!) but the code is written to make it 1, so make sure that it is. assert forHeader == 1; // Write the blocks that will will contain the header blocks. chan.position(dirPosition + (long) forHeader * Dirent.ENTRY_SIZE); for (DirectoryEntry dir : entries.values()) { Dirent ent = (Dirent) dir; if (!ent.isSpecial()) { log.debug("wrting ", dir.getFullName(), " at ", chan.position()); log.debug("ent size", ent.getSize()); ent.sync(chan); } } long end = (long) blockSize * headerBlockManager.getMaxBlock(); ByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position())); for (int i = 0; i < buf.capacity(); i++) buf.put((byte) 0); buf.flip(); chan.write(buf); // Now go back and write in the directory entry for the header. chan.position(dirPosition); Dirent ent = (Dirent) entries.values().iterator().next(); log.debug("ent header size", ent.getSize()); ent.sync(chan); } /** * Get the entries. Used for listing the directory. * * @return A list of the directory entries. They will be in the same * order as in the file. */ public List getEntries() { return new ArrayList(entries.values()); } /** * Add an entry to the directory. * * @param ent The entry to add. */ private void addEntry(DirectoryEntry ent) { entries.put(ent.getFullName(), ent); } public void setFile(ImgChannel chan) { this.chan = chan; } public void setStartPos(long startPos) { this.startPos = startPos; } public DirectoryEntry lookup(String name) { return entries.get(name); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/Dirent.java0000644000076400007640000001546711114073674021757 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 30-Nov-2006 */ package uk.me.parabola.imgfmt.sys; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import uk.me.parabola.imgfmt.Utils; import uk.me.parabola.imgfmt.fs.DirectoryEntry; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * An entry within a directory. This holds its name and a list * of blocks that go to make up this file. * * A directory entry may take more than block in the file system. * *

All documentation seems to point to the block numbers having to be * contiguous, but seems strange so I shall experiment. * *

Entries are in blocks of 512 bytes, regardless of the block size. * * @author Steve Ratcliffe */ class Dirent implements DirectoryEntry { protected static final Logger log = Logger.getLogger(Dirent.class); // Constants. static final int MAX_FILE_LEN = 8; static final int MAX_EXT_LEN = 3; // Offsets static final int OFF_FILE_USED = 0x00; static final int OFF_NAME = 0x01; static final int OFF_EXT = 0x09; static final int OFF_FLAG = 0x10; static final int OFF_FILE_PART = 0x11; private static final int OFF_SIZE = 0x0c; static final int ENTRY_SIZE = 512; // Filenames are a base+extension private String name; private String ext; // The file size. private int size; private final BlockManager blockManager; // The block table holds all the blocks that belong to this file. The // documentation suggests that block numbers are always contiguous. private final BlockTable blockTable; private boolean special; private static final int OFF_USED_FLAG = 0; private boolean initialized; Dirent(String name, BlockManager blockManager) { this.blockManager = blockManager; int dot = name.indexOf('.'); if (dot >= 0) { setName(name.substring(0, dot)); setExt(name.substring(dot+1)); } else throw new IllegalArgumentException("Filename did not have dot"); blockTable = new BlockTable(); } /** * Write this entry out to disk. Note that these are 512 bytes, regardless * of the blocksize. * * @param file The file to write to. * @throws IOException If writing fails for any reason. */ void sync(ImgChannel file) throws IOException { int ntables = blockTable.getNBlockTables(); ByteBuffer buf = ByteBuffer.allocate(ENTRY_SIZE * ntables); buf.order(ByteOrder.LITTLE_ENDIAN); for (int part = 0; part < ntables; part++) { log.debug("position at part", part, "is", buf.position()); buf.put((byte) 1); buf.put(Utils.toBytes(name, MAX_FILE_LEN, (byte) ' ')); buf.put(Utils.toBytes(ext, MAX_EXT_LEN, (byte) ' ')); // Size is only present in the first part if (part == 0) { log.debug("dirent", name, '.', ext, "size is going to", size); buf.putInt(size); } else { buf.putInt(0); } buf.put((byte) (special? 0x3: 0)); buf.putChar((char) part); // Write out the allocation of blocks for this entry. buf.position(ENTRY_SIZE * part + 0x20); blockTable.writeTable(buf, part); } buf.flip(); file.write(buf); } /** * Get the file name. * * @return The file name. */ public String getName() { return name; } /** * Get the file extension. * * @return The file extension. */ public String getExt() { return ext; } /** * The full name is of the form 8+3 with a dot in between the name and * extension. The full name is used as the index in the directory. * * @return The full name. */ public String getFullName() { return name + '.' + ext; } /** * Read in the block numbers from the given buffer. If this is the first * directory block for this file, then the size is set too. * * @param buf The data as read from the file. */ void initBlocks(ByteBuffer buf) { byte used = buf.get(OFF_USED_FLAG); if (used != 1) return; int part = buf.get(OFF_FILE_PART) & 0xff; if (part == 0 || (isSpecial() && part == 3)) size = buf.getInt(OFF_SIZE); blockTable.readTable(buf); initialized = true; } /** * Get the file size. * * @return The size of the file in bytes. */ public int getSize() { return size; } /** * Set the file name. The name should be exactly eight characters long * and it is truncated or left padded with zeros to make this true. * * @param name The file name. */ private void setName(String name) { int len = name.length(); if (len > MAX_FILE_LEN) { this.name = name.substring(0, 8); } else if (len < MAX_FILE_LEN) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < MAX_FILE_LEN - len; i++) { sb.append('0'); } sb.append(name); this.name = sb.toString(); } else this.name = name; } /** * Set the file extension. Can't be longer than three characters. * @param ext The file extension. */ private void setExt(String ext) { log.debug("ext len", ext.length()); if (ext.length() != MAX_EXT_LEN) throw new IllegalArgumentException("File extension is wrong size"); this.ext = ext; } /** * The number of blocks that the header covers. The header includes * the directory for the purposes of this routine. * * @return The total number of header basic blocks (blocks of 512 bytes). */ int numberHeaderBlocks() { return blockTable.getNBlockTables(); } void setSize(int size) { if (log.isDebugEnabled()) log.debug("setting size", getName(), getExt(), "to", size); this.size = size; } /** * Add a block without increasing the size of the file. * * @param n The block number. */ void addBlock(int n) { blockTable.addBlock(n); } /** * Set for the first directory entry that covers the header and directory * itself. * * @param special Set to true to mark as the special first entry. */ public void setSpecial(boolean special) { this.special = special; } public boolean isSpecial() { return special; } /** * Converts from a logical block to a physical block. If the block does * not exist then 0xffff will be returned. * * @param lblock The logical block in the file. * @return The corresponding physical block in the filesystem. */ public int getPhysicalBlock(int lblock) { return blockTable.physFromLogical(lblock); } public BlockManager getBlockManager() { return blockManager; } protected void setInitialized(boolean initialized) { this.initialized = initialized; } protected boolean isInitialized() { return initialized; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/BlockManager.java0000644000076400007640000000340011146610667023043 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 25-Oct-2007 */ package uk.me.parabola.imgfmt.sys; import uk.me.parabola.imgfmt.ExitException; import uk.me.parabola.log.Logger; /** * This is used to allocate blocks for files in the filesystem/archive. * * @author Steve Ratcliffe */ class BlockManager { private static final Logger log = Logger.getLogger(BlockManager.class); private int currentBlock; private final int blockSize; private int maxBlock = 0xfffe; BlockManager(int blockSize, int initialBlock) { this.blockSize = blockSize; this.currentBlock = initialBlock; } /** * Well the algorithm is pretty simple - you just get the next unused block * number. * * @return A block number that is free to be used. */ public int allocate() { int n = currentBlock++; if (maxBlock > 0 && n > maxBlock) { log.error("overflowed directory with max block " + maxBlock + ", current=" + n); throw new ExitException( "There is not enough room in a single garmin map for all the input data\n" + " The .osm file should be split into smaller pieces first."); } return n; } public int getBlockSize() { return blockSize; } public int getMaxBlock() { return maxBlock; } public void setMaxBlock(int maxBlock) { this.maxBlock = maxBlock; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/package.html0000644000076400007640000000056611154317465022145 0ustar stevesteve

Filesystem implementation

This holds the filesystem implementation for the .img format. I refer through out to a file system containing files, rather than using the term sub-files as in John Mechalas' document.

Another way to look at it (and probably a better one) is that it a kind of archive format just like a .zip file.

mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/ImgFS.java0000644000076400007640000002300611114073674021463 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 26-Nov-2006 */ package uk.me.parabola.imgfmt.sys; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.util.List; import uk.me.parabola.imgfmt.FileExistsException; import uk.me.parabola.imgfmt.FileNotWritableException; import uk.me.parabola.imgfmt.FileSystemParam; import uk.me.parabola.imgfmt.fs.DirectoryEntry; import uk.me.parabola.imgfmt.fs.FileSystem; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * The img file is really a filesystem containing several files. * It is made up of a header, a directory area and a data area which * occur in the filesystem in that order. * * @author steve */ public class ImgFS implements FileSystem { private static final Logger log = Logger.getLogger(ImgFS.class); // The directory is just like any other file, but with a name of 8+3 spaces static final String DIRECTORY_FILE_NAME = " . "; // This is the read or write channel to the real file system. private final FileChannel file; private boolean readOnly = true; // The header contains general information. private ImgHeader header; // There is only one directory that holds all filename and block allocation // information. private Directory directory; // The filesystem is responsible for allocating blocks private BlockManager fileBlockManager; private static final long BASIC_BLOCK_SIZE = (long) 512; /** * Private constructor, use the static {@link #createFs} and {@link #openFs} * routines to make a filesystem. * * @param chan The open file. */ private ImgFS(FileChannel chan) { file = chan; } /** * Create an IMG file from its external filesystem name and optionally some * parameters. * * @param filename The name of the file to be created. * @param params File system parameters. Can not be null. * @throws FileNotWritableException If the file can not be written to. */ public static FileSystem createFs(String filename, FileSystemParam params) throws FileNotWritableException { try { RandomAccessFile rafile = new RandomAccessFile(filename, "rw"); return createFs(rafile.getChannel(), params); } catch (FileNotFoundException e) { throw new FileNotWritableException("Could not create file", e); } } private static FileSystem createFs(FileChannel chan, FileSystemParam params) throws FileNotWritableException { assert params != null; // Truncate the file, because extra bytes beyond the end make for a // map that doesn't work on the GPS (although its likely to work in // other software viewers). try { chan.truncate(0); } catch (IOException e) { throw new FileNotWritableException("Failed to truncate file", e); } ImgFS fs = new ImgFS(chan); fs.createInitFS(chan, params); return fs; } /** * Open an existing IMG file system. * @param name The file name to open. * @return A File system that can be used lookup the internal files. * @throws FileNotFoundException When the file doesn't exist or can't be * read. */ public static FileSystem openFs(String name) throws FileNotFoundException { RandomAccessFile rafile = new RandomAccessFile(name, "r"); return openFs(rafile.getChannel()); } private static FileSystem openFs(FileChannel chan) throws FileNotFoundException { ImgFS fs = new ImgFS(chan); try { fs.readInitFS(chan); } catch (IOException e) { throw new FileNotFoundException("Failed to read header"); } return fs; } /** * Create a new file, it must not allready exist. * * @param name The file name. * @return A directory entry for the new file. */ public ImgChannel create(String name) throws FileExistsException { Dirent dir = directory.create(name, fileBlockManager); return new FileNode(file, dir, "w"); } /** * Open a file. The returned file object can be used to read and write the * underlying file. * * @param name The file name to open. * @param mode Either "r" for read access, "w" for write access or "rw" * for both read and write. * @return A file descriptor. * @throws FileNotFoundException When the file does not exist. */ public ImgChannel open(String name, String mode) throws FileNotFoundException { if (name == null || mode == null) throw new IllegalArgumentException("null argument"); if (mode.indexOf('r') >= 0) { Dirent ent = internalLookup(name); return new FileNode(file, ent, "r"); } else if (mode.indexOf('w') >= 0) { Dirent ent; try { ent = internalLookup(name); } catch (FileNotFoundException e) { try { ent = directory.create(name, fileBlockManager); } catch (FileExistsException e1) { // This shouldn't happen as we have just checked. throw new FileNotFoundException("Attempt to duplicate a file name"); } } return new FileNode(file, ent, "w"); } else { throw new IllegalArgumentException("Invalid mode given"); } } /** * Lookup the file and return a directory entry for it. * * @param name The filename to look up. * @return A directory entry. * @throws FileNotFoundException If an error occurs looking for the file, * including it not existing. */ public DirectoryEntry lookup(String name) throws FileNotFoundException { return internalLookup(name); } /** * List all the files in the directory. * * @return A List of directory entries. */ public List list() { return directory.getEntries(); } public FileSystemParam fsparam() { return header.getParams(); } /** * Sync with the underlying file. All unwritten data is written out to * the underlying file. * * @throws IOException If an error occurs during the write. */ public void sync() throws IOException { if (readOnly) return; header.sync(); directory.sync(); } /** * Close the filesystem. Any saved data is flushed out. It is better * to explicitly sync the data out first, to be sure that it has worked. */ public void close() { try { sync(); } catch (IOException e) { log.debug("could not sync filesystem"); } finally { try { file.close(); } catch (IOException e) { log.warn("Could not close file"); } } } /** * Set up and ImgFS that has just been created. * * @param chan The real underlying file to write to. * @param params The file system parameters. * @throws FileNotWritableException If the file cannot be written for any * reason. */ private void createInitFS(FileChannel chan, FileSystemParam params) throws FileNotWritableException { readOnly = false; // The block manager allocates blocks for files. BlockManager headerBlockManager = new BlockManager(params.getBlockSize(), 0); headerBlockManager.setMaxBlock(params.getReservedDirectoryBlocks()); // This bit is tricky. We want to use a regular ImgChannel to write // to the header and directory, but to create one normally would involve // it already existing, so it is created by hand. try { directory = new Directory(headerBlockManager); Dirent ent = directory.create(DIRECTORY_FILE_NAME, headerBlockManager); ent.setSpecial(true); ent.setInitialized(true); FileNode f = new FileNode(chan, ent, "w"); directory.setFile(f); header = new ImgHeader(f); header.createHeader(params); } catch (FileExistsException e) { throw new FileNotWritableException("Could not create img file directory", e); } fileBlockManager = new BlockManager(params.getBlockSize(), params.getReservedDirectoryBlocks()); assert directory != null && header != null; } /** * Initialise a filesystem that is going to be read from. We need to read * in the header including directory. * * @param chan The file channel to read from. * @throws IOException If the file cannot be read. */ private void readInitFS(FileChannel chan) throws IOException { ByteBuffer headerBuf = ByteBuffer.allocate(512); headerBuf.order(ByteOrder.LITTLE_ENDIAN); chan.read(headerBuf); header = new ImgHeader(null); header.setHeader(headerBuf); FileSystemParam params = header.getParams(); BlockManager headerBlockManager = new BlockManager(params.getBlockSize(), 0); headerBlockManager.setMaxBlock(params.getReservedDirectoryBlocks()); directory = new Directory(headerBlockManager); directory.setStartPos(params.getDirectoryStartBlock() * BASIC_BLOCK_SIZE); Dirent ent = directory.create(DIRECTORY_FILE_NAME, headerBlockManager); FileNode f = new FileNode(chan, ent, "r"); header.setFile(f); directory.setFile(f); directory.readInit(); } /** * Lookup the file and return a directory entry for it. * * @param name The filename to look up. * @return A directory entry. * @throws FileNotFoundException If an error occurs reading the directory. */ private Dirent internalLookup(String name) throws FileNotFoundException { if (name == null) throw new IllegalArgumentException("null name argument"); Dirent ent = (Dirent) directory.lookup(name); if (ent == null) throw new FileNotFoundException(name + " not found"); return ent; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/sys/ImgHeader.java0000644000076400007640000002303011114073674022340 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 26-Nov-2006 */ package uk.me.parabola.imgfmt.sys; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Calendar; import java.util.Date; import uk.me.parabola.imgfmt.FileSystemParam; import uk.me.parabola.imgfmt.Utils; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * The header at the very begining of the .img filesystem. It has the * same signature as a DOS partition table, although I don't know * exactly how much the partition concepts are used. * * @author Steve Ratcliffe */ class ImgHeader { private static final Logger log = Logger.getLogger(ImgHeader.class); // Offsets into the header. private static final int OFF_XOR = 0x0; private static final int OFF_UPDATE_MONTH = 0xa; private static final int OFF_UPDATE_YEAR = 0xb; // +1900 for val >= 0x63, +2000 for less private static final int OFF_CHECKSUM = 0xf; private static final int OFF_SIGNATURE = 0x10; private static final int OFF_UNK_1 = 0x17; // If this was a real boot sector these would be the meanings private static final int OFF_SECTORS = 0x18; private static final int OFF_HEADS = 0x1a; private static final int OFF_CYLINDERS = 0x1c; private static final int OFF_CREATION_YEAR = 0x39; // private static final int OFF_CREATION_MONTH = 0x3b; // private static final int OFF_CREATION_DAY = 0x3c; // private static final int OFF_CREATION_HOUR = 0x3d; // private static final int OFF_CREATION_MINUTE = 0x3e; // private static final int OFF_CREATION_SECOND = 0x3f; // The block number where the directory starts. private static final int OFF_DIRECTORY_START_BLOCK = 0x40; private static final int OFF_MAP_FILE_INTENTIFIER = 0x41; private static final int OFF_MAP_DESCRIPTION = 0x49; // 0x20 padded private static final int OFF_HEADS2 = 0x5d; private static final int OFF_SECTORS2 = 0x5f; private static final int OFF_BLOCK_SIZE_EXPONENT1 = 0x61; private static final int OFF_BLOCK_SIZE_EXPONENT2 = 0x62; private static final int OFF_BLOCK_SIZE = 0x63; // private static final int OFF_UKN_3 = 0x63; private static final int OFF_MAP_NAME_CONT = 0x65; // 'Partition table' offsets. private static final int OFF_START_HEAD = 0x1bf; private static final int OFF_START_SECTOR = 0x1c0; private static final int OFF_START_CYLINDER = 0x1c1; private static final int OFF_SYSTEM_TYPE = 0x1c2; private static final int OFF_END_HEAD = 0x1c3; private static final int OFF_END_SECTOR = 0x1c4; private static final int OFF_END_CYLINDER = 0x1c5; private static final int OFF_REL_SECTORS = 0x1c6; private static final int OFF_NUMBER_OF_SECTORS = 0x1ca; private static final int OFF_PARTITION_SIG = 0x1fe; // Lengths of some of the fields private static final int LEN_MAP_NAME_CONT = 30; private static final int LEN_MAP_DESCRIPTION = 20; private FileSystemParam fsParams; private final ByteBuffer header = ByteBuffer.allocate(512); private ImgChannel file; private Date creationTime; // Signatures. private static final byte[] FILE_ID = { 'G', 'A', 'R', 'M', 'I', 'N', '\0'}; private static final byte[] SIGNATURE = { 'D', 'S', 'K', 'I', 'M', 'G', '\0'}; ImgHeader(ImgChannel chan) { this.file = chan; header.order(ByteOrder.LITTLE_ENDIAN); } /** * Create a header from scratch. * @param params File system parameters. */ void createHeader(FileSystemParam params) { this.fsParams = params; header.put(OFF_XOR, (byte) 0); // Set the block size. 2^(E1+E2) where E1 is always 9. int exp = 9; int bs = params.getBlockSize(); for (int i = 0; i < 32; i++) { bs >>>= 1; if (bs == 0) { exp = i; break; } } if (exp < 9) throw new IllegalArgumentException("block size too small"); header.put(OFF_BLOCK_SIZE_EXPONENT1, (byte) 0x9); header.put(OFF_BLOCK_SIZE_EXPONENT2, (byte) (exp - 9)); header.position(OFF_SIGNATURE); header.put(SIGNATURE); header.position(OFF_MAP_FILE_INTENTIFIER); header.put(FILE_ID); header.put(OFF_UNK_1, (byte) 0x2); // Acutally this may not be the directory start block, I am guessing - // always assume it is 2 anyway. header.put(OFF_DIRECTORY_START_BLOCK, (byte) fsParams.getDirectoryStartBlock()); // This sectors, head, cylinders stuff appears to be used by mapsource // and they have to be larger than the actual size of the map. It // doesn't appear to have any effect on a garmin device or other software. int sectors = 0x20; // 0x20 appears to be a max header.putShort(OFF_SECTORS, (short) sectors); int heads = 0x20; // 0x20 appears to be max header.putShort(OFF_HEADS, (short) heads); int cylinders = 0x100; // gives 128M will try more later header.putShort(OFF_CYLINDERS, (short) cylinders); header.putShort(OFF_HEADS2, (short) heads); header.putShort(OFF_SECTORS2, (short) sectors); header.position(OFF_CREATION_YEAR); Utils.setCreationTime(header, creationTime); // Since there are only 2 bytes here but it can easily overflow, if it // does we replace it with 0xffff, it doesn't work to set it to say zero int blocks = heads * sectors * cylinders / (1 << exp - 9); char shortBlocks = blocks > 0xffff ? 0xffff : (char) blocks; header.putChar(OFF_BLOCK_SIZE, shortBlocks); header.put(OFF_PARTITION_SIG, (byte) 0x55); header.put(OFF_PARTITION_SIG+1, (byte) 0xaa); header.put(OFF_START_HEAD, (byte) 0); header.put(OFF_START_SECTOR, (byte) 1); header.put(OFF_START_CYLINDER, (byte) 0); header.put(OFF_SYSTEM_TYPE, (byte) 0); header.put(OFF_END_HEAD, (byte) (heads - 1)); header.put(OFF_END_SECTOR, (byte) sectors); header.put(OFF_END_CYLINDER, (byte) (cylinders - 1)); header.putInt(OFF_REL_SECTORS, 0); header.putInt(OFF_NUMBER_OF_SECTORS, (blocks * (1 << (exp - 9)))); log.info("number of blocks " + blocks); setDirectoryStartBlock(params.getDirectoryStartBlock()); // Set the times. Date date = new Date(); setCreationTime(date); setUpdateTime(date); setDescription(params.getMapDescription()); // Checksum is not checked. int check = 0; header.put(OFF_CHECKSUM, (byte) check); } void setHeader(ByteBuffer buf) { buf.flip(); header.put(buf); byte exp1 = header.get(OFF_BLOCK_SIZE_EXPONENT1); byte exp2 = header.get(OFF_BLOCK_SIZE_EXPONENT2); log.debug("header exponent", exp1, exp2); fsParams = new FileSystemParam(); fsParams.setBlockSize(1 << (exp1 + exp2)); fsParams.setDirectoryStartBlock(header.get(OFF_DIRECTORY_START_BLOCK)); StringBuffer sb = new StringBuffer(); sb.append(Utils.bytesToString(buf, OFF_MAP_DESCRIPTION, LEN_MAP_DESCRIPTION)); sb.append(Utils.bytesToString(buf, OFF_MAP_NAME_CONT, LEN_MAP_NAME_CONT)); fsParams.setMapDescription(sb.toString().trim()); // ... more to do } void setFile(ImgChannel file) { this.file = file; } FileSystemParam getParams() { return fsParams; } /** * Sync the header to disk. * @throws IOException If an error occurs during writing. */ public void sync() throws IOException { setUpdateTime(new Date()); header.rewind(); file.position(0); file.write(header); file.position(fsParams.getDirectoryStartBlock() * (long) 512); } /** * Set the update time. * @param date The date to use. */ protected void setUpdateTime(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); header.put(OFF_UPDATE_YEAR, toYearCode(cal.get(Calendar.YEAR))); header.put(OFF_UPDATE_MONTH, (byte) (cal.get(Calendar.MONTH)+1)); } /** * Set the description. It is spread across two areas in the header. * @param desc The description. */ protected void setDescription(String desc) { int len = desc.length(); if (len > 50) throw new IllegalArgumentException("Description is too long (max 50)"); String part1, part2; if (len > LEN_MAP_DESCRIPTION) { part1 = desc.substring(0, LEN_MAP_DESCRIPTION); part2 = desc.substring(LEN_MAP_DESCRIPTION, len); } else { part1 = desc.substring(0, len); part2 = ""; } header.position(OFF_MAP_DESCRIPTION); header.put(toByte(part1)); for (int i = len; i < LEN_MAP_DESCRIPTION; i++) header.put((byte) ' '); header.position(OFF_MAP_NAME_CONT); header.put(toByte(part2)); for (int i = Math.max(len - LEN_MAP_DESCRIPTION, 0); i < LEN_MAP_NAME_CONT; i++) header.put((byte) ' '); header.put((byte) 0); // really? } /** * Convert a string to a byte array. * @param s The string * @return A byte array. */ private byte[] toByte(String s) { // NB: what character set should be used? return s.getBytes(); } /** * Convert to the one byte code that is used for the year. * If the year is in the 1900, then subtract 1900 and add the result to 0x63, * else subtract 2000. * Actually looks simpler, just subtract 1900.. * @param y The year in real-world format eg 2006. * @return A one byte code representing the year. */ private byte toYearCode(int y) { return (byte) (y - 1900); } protected void setDirectoryStartBlock(int directoryStartBlock) { header.put(OFF_DIRECTORY_START_BLOCK, (byte) directoryStartBlock); fsParams.setDirectoryStartBlock(directoryStartBlock); } protected void setCreationTime(Date date) { this.creationTime = date; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/package.html0000644000076400007640000000210110666506051021310 0ustar stevesteve

The IMG file format

The IMG file is internally structured like a file-system containing a number of files and a directory. It is common to refer to the whole thing as a file and the contained files as sub-files. However I use the terms file system and file respectively, because it is more descriptive of what is going on I think.

There are two main sub-packages here.

fs
This deals with filesystem as a whole. The individual files are just blobs of data. You could handle any filename at this level.
app
Code for actual application files that are used. Code in here knows about the internal structure of individual files.

As the purpose of this application is to write IMG files (there are plenty of programs that read it), the focus is on writing and not reading. The code to read at the filesystem level will probably be implemented at some stage so that we can combine several .img files into one gmapsupp.img file.

mkgmap-r1067/src/uk/me/parabola/imgfmt/FileExistsException.java0000644000076400007640000000222710666506051023641 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 02-Dec-2006 */ package uk.me.parabola.imgfmt; import java.io.IOException; /** * Thrown when a file already exists and would be overwritten. * * @author Steve Ratcliffe */ public class FileExistsException extends IOException { /** * Constructs a new exception with the specified detail message. The * cause is not initialized, and may subsequently be initialized by * a call to {@link #initCause}. * * @param message the detail message. The detail message is saved for * later retrieval by the {@link #getMessage()} method. */ public FileExistsException(String message) { super(message); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/0000755000076400007640000000000011216306457017634 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/mps/Block.java0000644000076400007640000000400611110050256021513 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 19, 2007 */ package uk.me.parabola.imgfmt.mps; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.io.StructuredOutputStream; /** * All the blocks in the file have a type and a length. * * @author Steve Ratcliffe */ public abstract class Block { private final int type; private final ByteArrayOutputStream output = new ByteArrayOutputStream(); protected Block(int type) { this.type = type; } public void write(ImgChannel chan) throws IOException { // First write the body to the byte buffer so that we know its length. writeBody(new StructuredOutputStream(output)); ByteBuffer buf = ByteBuffer.allocate(16); buf.order(ByteOrder.LITTLE_ENDIAN); buf.put((byte) type); char len = getLength(); buf.putChar(len); // write the header. buf.flip(); chan.write(buf); // write the body. buf = ByteBuffer.allocate(len); buf.put(output.toByteArray()); buf.flip(); chan.write(buf); } /** * Writes the body to the output stream given. * * @param out The stream to write to. */ protected abstract void writeBody(StructuredOutputStream out) throws IOException; /** * This is only valid after everything is written to the block. * * @return The length of the block (or the amount written already). */ private char getLength() { int len = output.toByteArray().length; assert len <= 0xffff; return (char) len; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/MapBlock.java0000644000076400007640000000321010763340724022164 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 19, 2007 */ package uk.me.parabola.imgfmt.mps; import uk.me.parabola.io.StructuredOutputStream; import java.io.IOException; /** * A block describing an individual map. * * @author Steve Ratcliffe */ public class MapBlock extends Block { private static final int BLOCK_TYPE = 0x4c; private int productId; private int mapNumber; private String typeName; private String mapName; private String areaName; public MapBlock() { super(BLOCK_TYPE); } protected void writeBody(StructuredOutputStream out) throws IOException { out.write4(productId); out.write4(mapNumber); out.writeString(typeName); out.writeString(mapName); out.writeString(areaName); out.write4(mapNumber); out.write4(0); } public void setIds(int familyId, int productId) { this.productId = (familyId << 16) | productId; } public void setTypeName(String typeName) { this.typeName = typeName; } public void setMapNumber(int mapNumber) { this.mapNumber = mapNumber; } public void setMapName(String mapName) { this.mapName = mapName; } public void setAreaName(String areaName) { this.areaName = areaName; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/MpsFile.java0000644000076400007640000000464410735217321022042 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 19, 2007 */ package uk.me.parabola.imgfmt.mps; import uk.me.parabola.imgfmt.fs.ImgChannel; import java.util.List; import java.util.ArrayList; import java.io.IOException; /** * This file is a description of the map set that is loaded into the * gmapsupp.img file and an index of the maps that it contains. * * It is different than all the other files that fit inside the gmapsupp file * in that it doesn't contain the common header. So it does not extend ImgFile. * * @author Steve Ratcliffe */ public class MpsFile { private int productId; //private int productVersion = 1; private String seriesName = "OSM map sets"; private String familyName = "OSM maps"; private final ProductBlock product = new ProductBlock(); private final MapsetBlock mapset = new MapsetBlock(); private final List maps = new ArrayList(); private final ImgChannel chan; public MpsFile(ImgChannel chan) { this.chan = chan; } public void sync() throws IOException { product.setProduct(productId); product.setDescription(familyName); // XXX or seriesName mapset.setName(seriesName); // XXX or family for (MapBlock map : maps) { map.write(chan); } mapset.write(chan); product.write(chan); } public void addMap(MapBlock map) { maps.add(map); } public void setProductInfo(int productId, String seriesName, String familyName) { this.productId = productId; //this.productVersion = productVersion; this.seriesName = seriesName; this.familyName = familyName; } public void setProductId(int productId) { this.productId = productId; } //public void setProductVersion(int productVersion) { // this.productVersion = productVersion; //} public void setSeriesName(String seriesName) { this.seriesName = seriesName; } public void setFamilyName(String familyName) { this.familyName = familyName; } public void close() throws IOException { chan.close(); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/ProductBlock.java0000644000076400007640000000242011146630304023061 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 19, 2007 */ package uk.me.parabola.imgfmt.mps; import java.io.IOException; import uk.me.parabola.io.StructuredOutputStream; /** * A block describing a particular product. Not sure how this relates * to the map set. * * @author Steve Ratcliffe */ public class ProductBlock extends Block { private static final int BLOCK_TYPE = 0x46; private int product; private String description = "OSM maps"; public ProductBlock() { super(BLOCK_TYPE); } protected void writeBody(StructuredOutputStream out) throws IOException { out.write4(product); out.writeString(description); } public void setProduct(int product) { this.product = product; } public void setDescription(String description) { this.description = description; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/package.html0000644000076400007640000000147310732231653022117 0ustar stevesteve

The MPS file

This file is similar to the TDB file in that it is a list of maps along with other information describing the set. It is inserted into the gmapsupp.img file. Maps appear to work without it, so I don't know what effect it has - is it informational, or does it help speed operations by providing an index? I don't know.

It isn't like the other files in the app package, for a start it doesn't begin with the common header. It should perhaps live with the TDB format or in a similar top level place. It is here because it is included inside the gmapsupp.img file and doesn't normally have a separate existance.

The names and lengths of the fields were obtained from the program gpsexplorer by the author identified as 'garminmaploader@yahoo.com' and released under GPL2+.

mkgmap-r1067/src/uk/me/parabola/imgfmt/mps/MapsetBlock.java0000644000076400007640000000215510763340724022707 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 19, 2007 */ package uk.me.parabola.imgfmt.mps; import uk.me.parabola.io.StructuredOutputStream; import java.io.IOException; /** * Block describing the map set. * * @author Steve Ratcliffe */ public class MapsetBlock extends Block { private static final int BLOCK_TYPE = 0x56; private String name = "OSM map set"; public MapsetBlock() { super(BLOCK_TYPE); } protected void writeBody(StructuredOutputStream out) throws IOException { out.writeString(name); out.write(0); // unknown } public void setName(String name) { if (name != null) this.name = name; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/0000755000076400007640000000000011216306457017615 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/ImgFileWriter.java0000644000076400007640000000470611054371063023173 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 07-Dec-2006 */ package uk.me.parabola.imgfmt.app; import java.io.IOException; import java.io.Closeable; /** * I want to be able to experiment with different schemes to write out. * * I am hoping that you do not need to write files with contiguous blocks, * however since all maps seem to do that it may not be possible. Having a block * list is then a bit strange. Perhaps you can but it performs worse so no one * does it? * * @author Steve Ratcliffe */ public interface ImgFileWriter extends Closeable { /** * Called to write out any saved buffers. The strategy may write * directly to the file in which case this would have nothing or * little to do. * @throws IOException If there is an error writing. */ public void sync() throws IOException; /** * Get the position. Needed because may not be reflected in the underlying * file if being buffered. * * @return The logical position within the file. */ public int position(); /** * Set the position of the file. * @param pos The new position in the file. */ void position(long pos); /** * Write out a single byte. * @param b The byte to write. */ public void put(byte b); /** * Write out two bytes. Done in the correct byte order. * @param c The value to write. */ public void putChar(char c); /** * Write out three bytes. Done in the correct byte order. * * @param val The value to write, only the bottom three bytes will be * written. */ public void put3(int val); /** * Write out 4 byte value. * @param val The value to write. */ public void putInt(int val); /** * Write out an arbitary length sequence of bytes. * * @param val The values to write. */ void put(byte[] val); /** * Write out part of a byte array. * * @param src The array to take bytes from. * @param start The start position. * @param length The number of bytes to write. */ void put(byte[] src, int start, int length); } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/0000755000076400007640000000000011216306457020366 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/Country.java0000644000076400007640000000224711164230243022670 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.ImgFileWriter; /** * A country contains one or more regions. * * @author Steve Ratcliffe */ public class Country { // The country number. This is not recorded in the file private final char index; private Label label; public Country(int index) { this.index = (char) index; } void write(ImgFileWriter writer) { writer.put3(label.getOffset()); } public char getIndex() { return index; } public void setLabel(Label label) { this.label = label; } public Label getLabel() { return label; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java0000644000076400007640000001543111177352240022443 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 */ package uk.me.parabola.imgfmt.app.lbl; import java.util.HashMap; import java.util.Map; import uk.me.parabola.imgfmt.Utils; import uk.me.parabola.imgfmt.app.BufferedImgFileReader; import uk.me.parabola.imgfmt.app.BufferedImgFileWriter; import uk.me.parabola.imgfmt.app.ImgFile; import uk.me.parabola.imgfmt.app.ImgFileReader; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.labelenc.BaseEncoder; import uk.me.parabola.imgfmt.app.labelenc.CharacterDecoder; import uk.me.parabola.imgfmt.app.labelenc.CharacterEncoder; import uk.me.parabola.imgfmt.app.labelenc.CodeFunctions; import uk.me.parabola.imgfmt.app.labelenc.EncodedText; import uk.me.parabola.imgfmt.app.trergn.Subdivision; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; import uk.me.parabola.imgfmt.app.Exit; /** * The file that holds all the labels for the map. * * Would be quite simple, but there are a number of sections that hold country, * region, city, etc. records. * * To begin with I shall only support regular labels. * * @author Steve Ratcliffe */ public class LBLFile extends ImgFile { private static final Logger log = Logger.getLogger(LBLFile.class); private CharacterEncoder textEncoder = CodeFunctions.getDefaultEncoder(); private CharacterDecoder textDecoder = CodeFunctions.getDefaultDecoder(); private final Map labelCache = new HashMap(); private final LBLHeader lblHeader = new LBLHeader(); private final PlacesFile places = new PlacesFile(); public LBLFile(ImgChannel chan) { this(chan, true); } public LBLFile(ImgChannel chan, boolean write) { setHeader(lblHeader); if (write) { setWriter(new BufferedImgFileWriter(chan)); position(LBLHeader.HEADER_LEN + LBLHeader.INFO_LEN); // The zero offset is for no label. getWriter().put((byte) 0); } else { setReader(new BufferedImgFileReader(chan)); lblHeader.readHeader(getReader()); CodeFunctions funcs = CodeFunctions.createEncoderForLBL( lblHeader.getEncodingType()); textEncoder = funcs.getEncoder(); textDecoder = funcs.getDecoder(); } places.init(this, lblHeader.getPlaceHeader()); } public void write() { writeBody(); } public void writePost() { // Now that the body is written all the required offsets will be set up // inside the header, so we can go back and write it. getHeader().writeHeader(getWriter()); // Text can be put between the header and the body of the file. getWriter().put(Utils.toBytes("mkgmap")); } private void writeBody() { // The label section has already been written, but we need to record // its size before doing anything else. lblHeader.setLabelSize(getWriter().position() - (LBLHeader.HEADER_LEN + LBLHeader.INFO_LEN)); places.write(getWriter()); } public void setCharacterType(String cs, boolean forceUpper) { log.info("encoding type " + cs); CodeFunctions cfuncs = CodeFunctions.createEncoderForLBL(cs); lblHeader.setEncodingType(cfuncs.getEncodingType()); textEncoder = cfuncs.getEncoder(); if (forceUpper && textEncoder instanceof BaseEncoder) { BaseEncoder baseEncoder = (BaseEncoder) textEncoder; baseEncoder.setUpperCase(true); } textDecoder = cfuncs.getDecoder(); if (lblHeader.getCodePage() == 0) setCodePage(cfuncs.getCodepage()); } /** * Add a new label with the given text. Labels are shared, so that identical * text is always represented by the same label. * * @param text The text of the label, it will be uppercased. * @return A reference to the created label. */ public Label newLabel(String text) { EncodedText etext = textEncoder.encodeText(text); Label l = labelCache.get(text); if (l == null) { l = new Label(etext); labelCache.put(text, l); l.setOffset(position() - (LBLHeader.HEADER_LEN + LBLHeader.INFO_LEN)); l.write(getWriter()); } return l; } public POIRecord createPOI(String name) { return places.createPOI(name); } public POIRecord createExitPOI(String name, Exit exit) { return places.createExitPOI(name, exit); } public POIIndex createPOIIndex(String name, int poiIndex, Subdivision group, int type) { return places.createPOIIndex(name, poiIndex, group, type); } public Country createCountry(String name, String abbr) { return places.createCountry(name, abbr); } public Region createRegion(Country country, String region, String abbr) { return places.createRegion(country, region, abbr); } public City createCity(Region region, String city, boolean unique) { return places.createCity(region, city, unique); } public City createCity(Country country, String city, boolean unique) { return places.createCity(country, city, unique); } public Zip createZip(String code) { return places.createZip(code); } public Highway createHighway(Region region, String name) { return places.createHighway(region, name); } public ExitFacility createExitFacility(int type, char direction, int facilities, String description, boolean last) { return places.createExitFacility(type, direction, facilities, description, last); } public void allPOIsDone() { places.allPOIsDone(); } public void setCodePage(int codePage) { lblHeader.setCodePage(codePage); } /** * Bit of a shortcut to get a text string from the label file given its * offset. * @param offset Offset in the file. These offsets are used in the other * map files, such as RGN and NET. * @return The label as a string. Will be an empty string if there is no * text for the label. Note that this is particularly the case when the * offset is zero. */ public String fetchLableString(int offset) { // Short cut the simple case of no label if (offset == 0) return ""; // or null ??? ImgFileReader reader = getReader(); reader.position(lblHeader.getLabelStart() + offset); byte b; do { b = reader.get(); } while (!textDecoder.addByte(b)) ; EncodedText text = textDecoder.getText(); return new String(text.getCtext(), 0, text.getLength()); } public PlacesHeader getPlaceHeader() { return lblHeader.getPlaceHeader(); } public int numCities() { return places.numCities(); } public int numZips() { return places.numZips(); } public int numHighways() { return places.numHighways(); } public int numExitFacilities() { return places.numExitFacilities(); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/Zip.java0000644000076400007640000000220411034116042021754 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.ImgFileWriter; /** * A zip or postal code record. * * @author Steve Ratcliffe */ public class Zip { // The index is not stored in the file, you just use the index of it in // the section. private final int index; private Label label; public Zip(int index) { this.index = index; } public void write(ImgFileWriter writer) { writer.put3(label.getOffset()); } public void setLabel(Label label) { this.label = label; } public int getIndex() { return index; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java0000644000076400007640000002000611177352240023233 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import uk.me.parabola.imgfmt.app.trergn.Subdivision; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.util.Sortable; import uk.me.parabola.imgfmt.app.Exit; /** * This is really part of the LBLFile. We split out all the parts of the file * that are to do with location to here. */ public class PlacesFile { private final Map countries = new LinkedHashMap(); private final Map regions = new LinkedHashMap(); private final List> regionList = new ArrayList>(); private final Map cities = new LinkedHashMap(); private final List> cityList = new ArrayList>(); private final Map postalCodes = new LinkedHashMap(); private final List highways = new ArrayList(); private final List exitFacilities = new ArrayList(); private final List pois = new ArrayList(); private final List[] poiIndex = new ArrayList[256]; private LBLFile lblFile; private PlacesHeader placeHeader; private boolean poisClosed; //private Collator collator; /** * We need to have links back to the main LBL file and need to be passed * the part of the header that we manage here. * * @param file The main LBL file, used so that we can create lables. * @param pheader The place header. */ void init(LBLFile file, PlacesHeader pheader) { lblFile = file; placeHeader = pheader; //collator = Collator.getInstance(Locale.US); // TODO work out how this should work } void write(ImgFileWriter writer) { for (Country c : countries.values()) c.write(writer); placeHeader.endCountries(writer.position()); for (Sortable sr : regionList) sr.getValue().write(writer); placeHeader.endRegions(writer.position()); for (Sortable sc : cityList) sc.getValue().write(writer); placeHeader.endCity(writer.position()); for (List pil : poiIndex) { if(pil != null) { // sort entries by POI name Collections.sort(pil); for(POIIndex pi : pil) pi.write(writer); } } placeHeader.endPOIIndex(writer.position()); int poistart = writer.position(); byte poiglobalflags = placeHeader.getPOIGlobalFlags(); for (POIRecord p : pois) p.write(writer, poiglobalflags, writer.position() - poistart, cities.size(), postalCodes.size(), highways.size(), exitFacilities.size()); placeHeader.endPOI(writer.position()); int numPoiIndexEntries = 0; for (int i = 0; i < 256; ++i) { if(poiIndex[i] != null) { writer.put((byte)i); writer.put3(numPoiIndexEntries + 1); numPoiIndexEntries += poiIndex[i].size(); } } placeHeader.endPOITypeIndex(writer.position()); for (Zip z : postalCodes.values()) z.write(writer); placeHeader.endZip(writer.position()); int extraHighwayDataOffset = 0; for (Highway h : highways) { h.setExtraDataOffset(extraHighwayDataOffset); extraHighwayDataOffset += h.getExtraDataSize(); h.write(writer, false); } placeHeader.endHighway(writer.position()); for (ExitFacility ef : exitFacilities) ef.write(writer); placeHeader.endExitFacility(writer.position()); for (Highway h : highways) h.write(writer, true); placeHeader.endHighwayData(writer.position()); } Country createCountry(String name, String abbr) { String s = abbr != null ? name + (char)0x1d + abbr : name; Country c = countries.get(s); if(c == null) { c = new Country(countries.size()+1); Label l = lblFile.newLabel(s); c.setLabel(l); countries.put(s, c); } return c; } Region createRegion(Country country, String name, String abbr) { String s = abbr != null ? name + (char)0x1d + abbr : name; String uniqueRegionName = s.toUpperCase() + "_C" + country.getLabel().getOffset(); Region r = regions.get(uniqueRegionName); if(r == null) { r = new Region(country); Label l = lblFile.newLabel(s); r.setLabel(l); regionList.add(new Sortable(name, r)); regions.put(uniqueRegionName, r); } return r; } City createCity(Country country, String name, boolean unique) { String uniqueCityName = name.toUpperCase() + "_C" + country.getLabel().getOffset(); City c = null; if(!unique) c = cities.get(uniqueCityName); if(c == null) { c = new City(country); Label l = lblFile.newLabel(name); c.setLabel(l); cityList.add(new Sortable(name, c)); cities.put(uniqueCityName, c); } return c; } City createCity(Region region, String name, boolean unique) { String uniqueCityName = name.toUpperCase() + "_R" + region.getLabel().getOffset(); City c = null; if(!unique) c = cities.get(uniqueCityName); if(c == null) { c = new City(region); Label l = lblFile.newLabel(name); c.setLabel(l); cityList.add(new Sortable(name, c)); cities.put(uniqueCityName, c); } return c; } Zip createZip(String code) { Zip z = postalCodes.get(code); if(z == null) { z = new Zip(postalCodes.size()+1); Label l = lblFile.newLabel(code); z.setLabel(l); postalCodes.put(code, z); } return z; } Highway createHighway(Region region, String name) { Highway h = new Highway(region, highways.size()+1); Label l = lblFile.newLabel(name); h.setLabel(l); highways.add(h); return h; } public ExitFacility createExitFacility(int type, char direction, int facilities, String description, boolean last) { Label d = lblFile.newLabel(description); ExitFacility ef = new ExitFacility(type, direction, facilities, d, last, exitFacilities.size()+1); exitFacilities.add(ef); return ef; } POIRecord createPOI(String name) { assert !poisClosed; // TODO... POIRecord p = new POIRecord(); Label l = lblFile.newLabel(name); p.setLabel(l); pois.add(p); return p; } POIRecord createExitPOI(String name, Exit exit) { assert !poisClosed; // TODO... POIRecord p = new POIRecord(); Label l = lblFile.newLabel(name); p.setLabel(l); p.setExit(exit); pois.add(p); return p; } POIIndex createPOIIndex(String name, int index, Subdivision group, int type) { assert index < 0x100 : "Too many POIS in division"; POIIndex pi = new POIIndex(name, (byte)index, group, (byte)type); int t = type >> 8; if(poiIndex[t] == null) poiIndex[t] = new ArrayList(); poiIndex[t].add(pi); return pi; } void allPOIsDone() { int index = 1; Collections.sort(regionList); for (Sortable sr: regionList) sr.getValue().setIndex(index++); index = 1; Collections.sort(cityList); for (Sortable sc: cityList) sc.getValue().setIndex(index++); poisClosed = true; byte poiFlags = 0; for (POIRecord p : pois) { poiFlags |= p.getPOIFlags(); } placeHeader.setPOIGlobalFlags(poiFlags); int ofs = 0; for (POIRecord p : pois) ofs += p.calcOffset(ofs, poiFlags, cities.size(), postalCodes.size(), highways.size(), exitFacilities.size()); } public int numCities() { return cities.size(); } public int numZips() { return postalCodes.size(); } public int numHighways() { return highways.size(); } public int numExitFacilities() { return exitFacilities.size(); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/ExitFacility.java0000644000076400007640000000372111157711542023631 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.trergn.Subdivision; /** * Represent a facility at a motorway exit * * @author Mark Burton */ public class ExitFacility { private final int index; private Label description; private int type; // truck stop - 24 hour diesel + food private int direction; // undefined private int facilities; // none private boolean last; public ExitFacility(int type, char direction, int facilities, Label description, boolean last, int index) { this.type = type; this.direction = directionCode(direction); this.facilities = facilities; this.description = description; this.last = last; this.index = index; } void write(ImgFileWriter writer) { int word = 0; word |= description.getOffset(); // 0:21 = label offset // 22 = unknown if(last) word |= 1 << 23; // 23 = last facility for this exit word |= type << 24; // 24:27 = 4 bit type // 28 = unknown word |= direction << 29; // 29:31 = 3 bit direction writer.putChar((char)word); writer.putChar((char)(word >> 16)); writer.put((byte)facilities); } public int getIndex() { return index; } public boolean getOvernightParking() { return false; } private int directionCode(char direction) { int code = "NSEWIOB".indexOf(direction); if(code < 0) code = 7; // undefined return code; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/Highway.java0000644000076400007640000000466211157711542022640 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import java.util.ArrayList; import java.util.List; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.trergn.Subdivision; /** * A highway is in a region. * * @author Mark Burton */ public class Highway { class ExitPoint implements Comparable { String name; byte index; Subdivision div; public ExitPoint(String name, byte index, Subdivision div) { this.name = name; this.index = index; this.div = div; } public int compareTo(Object o) { return name.compareTo(((ExitPoint)o).name); } } private final int index; private final Region region; private final List exits = new ArrayList(); private Label label; private int extraDataOffset; // in 3-byte records - 1 based public Highway(Region region, int index) { this.region = region; this.index = index; } void write(ImgFileWriter writer, boolean extraData) { if(extraData) { writer.put((byte)0); writer.putChar((char)(region == null? 0 : region.getIndex())); java.util.Collections.sort(exits); for(ExitPoint ep : exits) { writer.put(ep.index); writer.putChar((char)ep.div.getNumber()); } } else { assert extraDataOffset != 0; writer.put3(label.getOffset()); writer.putChar((char)extraDataOffset); writer.put((byte)0); // unknown (setting any of 0x3f stops exits being found) } } public int getIndex() { return index; } public Region getRegion() { return region; } public void setLabel(Label label) { this.label = label; } public void setExtraDataOffset(int extraDataOffset) { this.extraDataOffset = extraDataOffset / 3 + 1; } public int getExtraDataSize() { return (1 + exits.size()) * 3; } public void addExitPoint(String name, int index, Subdivision div) { exits.add(new ExitPoint(name, (byte)index, div)); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/City.java0000644000076400007640000000621711164230243022136 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.trergn.Subdivision; /** * A city is in a region. It also has (or can have anyway) a reference to * an indexed point within the map itself. * * @author Steve Ratcliffe */ public class City implements Comparable { private static final int POINT_REF = 0x8000; private static final int REGION_IS_COUNTRY = 0x4000; private int index = -1; private final Region region; private final Country country; // This determines if a label is being used or a subdivision and point // combo. private boolean pointRef; // The location of the city. These could both be zero if we are using a // label instead. private Subdivision subdivision; private byte pointIndex; // You can have either a label or a subdivision and point. This will be // null if the location is being specified. private Label label; public City(Region region) { this.region = region; this.country = null; } public City(Country country) { this.country = country; this.region = null; } void write(ImgFileWriter writer) { //writer.put3() if (pointRef) { // System.err.println("City point = " + (int)pointIndex + " div = " + subdivision.getNumber()); writer.put(pointIndex); writer.putChar((char)subdivision.getNumber()); } else { writer.put3(label.getOffset()); } char info; if(region != null) info = (char) (region.getIndex() & 0x3fff); else info = (char) (REGION_IS_COUNTRY | (country.getIndex() & 0x3fff)); if (pointRef) info |= POINT_REF; writer.putChar(info); } public int getIndex() { if (index == -1) throw new IllegalStateException("Offset not known yet."); return index; } public void setIndex(int index) { this.index = index; } public void setLabel(Label label) { pointRef = false; this.label = label; } public void setPointIndex(byte pointIndex) { pointRef = true; this.pointIndex = pointIndex; } public void setSubdivision(Subdivision subdivision) { pointRef = true; this.subdivision = subdivision; } public int compareTo(Object other) { City o = (City)other; if(o == this) return 0; if(label != null && o.label != null) return label.compareTo(o.label); return hashCode() - o.hashCode(); } public String toString() { String result = ""; if(label != null) result += new String(label.getCtext()); if(country != null) result += " in country " + (0 + country.getIndex()); if(region != null) result += " in region " + (0 + region.getIndex()); return result; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/Region.java0000644000076400007640000000255211164230243022447 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.ImgFileWriter; /** * A region is in a country and contains one or more cities. * * @author Steve Ratcliffe */ public class Region { private char index; private final Country country; private Label label; public Region(Country country) { this.country = country; } public void write(ImgFileWriter writer) { writer.putChar(country.getIndex()); writer.put3(label.getOffset()); } public char getIndex() { assert index > 0 : "Index not yet set"; return index; } public Country getCountry() { return country; } public void setIndex(int index) { this.index = (char)index; } public void setLabel(Label label) { this.label = label; } public Label getLabel() { return label; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/package.html0000644000076400007640000000053110735217321022642 0ustar stevesteve

The LBL file

This file holds the textual labels. There are a number of different formats that the text is stored in, the default format is a space saving format that saves characters in 6 bits but doesn't allow for non-ascii characters.

This file can also hold region, town/city and point of interest names

mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/PlacesHeader.java0000644000076400007640000001245511157711542023557 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.Section; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.ImgFileReader; /** * This is not a separate header, but rather part of the LBL header. It is just * separated out for convenience. All the records that have some kind of * meaning associated with a place are put here. * * @author Steve Ratcliffe */ public class PlacesHeader { private static final char COUNTRY_REC_LEN = 3; private static final char REGION_REC_LEN = 5; private static final char CITY_REC_LEN = 5; private static final char POI_INDEX_REC_LEN = 4; private static final char POI_TYPE_INDEX_REC_LEN = 4; private static final char ZIP_REC_LEN = 3; private static final char HIGHWAY_REC_LEN = 6; private static final char EXIT_REC_LEN = 5; private static final char HIGHWAYDATA_REC_LEN = 3; private final Section country = new Section(COUNTRY_REC_LEN); private final Section region = new Section(country, REGION_REC_LEN); private final Section city = new Section(region, CITY_REC_LEN); private final Section poiIndex = new Section(city, POI_INDEX_REC_LEN); private final Section poiProperties = new Section(poiIndex); private final Section poiTypeIndex = new Section(poiProperties, POI_TYPE_INDEX_REC_LEN); private final Section zip = new Section(poiTypeIndex, ZIP_REC_LEN); private final Section highway = new Section(zip, HIGHWAY_REC_LEN); private final Section exitFacility = new Section(highway, EXIT_REC_LEN); private final Section highwayData = new Section(exitFacility, HIGHWAYDATA_REC_LEN); private byte POIGlobalFlags ; void setPOIGlobalFlags(byte flags) { this.POIGlobalFlags = flags; } byte getPOIGlobalFlags() { return POIGlobalFlags; } void writeFileHeader(ImgFileWriter writer) { writer.putInt(country.getPosition()); writer.putInt(country.getSize()); writer.putChar(country.getItemSize()); writer.putInt(0); writer.putInt(region.getPosition()); writer.putInt(region.getSize()); writer.putChar(region.getItemSize()); writer.putInt(0); writer.putInt(city.getPosition()); writer.putInt(city.getSize()); writer.putChar(city.getItemSize()); writer.putInt(0); writer.putInt(poiIndex.getPosition()); writer.putInt(poiIndex.getSize()); writer.putChar(poiIndex.getItemSize()); writer.putInt(0); writer.putInt(poiProperties.getPosition()); writer.putInt(poiProperties.getSize()); writer.put((byte) 0); // offset multiplier writer.put(POIGlobalFlags); // properties global mask writer.putChar((char) 0); writer.put((byte) 0); writer.putInt(poiTypeIndex.getPosition()); writer.putInt(poiTypeIndex.getSize()); writer.putChar(poiTypeIndex.getItemSize()); writer.putInt(0); writer.putInt(zip.getPosition()); writer.putInt(zip.getSize()); writer.putChar(zip.getItemSize()); writer.putInt(0); writer.putInt(highway.getPosition()); writer.putInt(highway.getSize()); writer.putChar(highway.getItemSize()); writer.putInt(0); writer.putInt(exitFacility.getPosition()); writer.putInt(exitFacility.getSize()); writer.putChar(exitFacility.getItemSize()); writer.putInt(0); writer.putInt(highwayData.getPosition()); writer.putInt(highwayData.getSize()); writer.putChar(highwayData.getItemSize()); writer.putInt(0); } void readFileHeader(ImgFileReader reader) { reader.position(0x1f); country.setPosition(reader.getInt()); country.setSize(reader.getInt()); country.setItemSize(reader.getChar()); reader.getInt(); region.setPosition(reader.getInt()); region.setSize(reader.getInt()); region.setItemSize(reader.getChar()); reader.getInt(); city.setPosition(reader.getInt()); city.setSize(reader.getInt()); city.setItemSize(reader.getChar()); reader.getInt(); } int getLastPos() { // Beware this is not really valid until all is written. return highwayData.getEndPos(); } void setLabelEnd(int pos) { country.setPosition(pos); } void endCountries(int pos) { country.setSize(pos - country.getPosition()); } void endRegions(int pos) { region.setSize(pos - region.getPosition()); } void endCity(int pos) { city.setSize(pos - city.getPosition()); } void endPOI(int pos) { poiProperties.setSize(pos - poiProperties.getPosition()); } void endPOIIndex(int pos) { poiIndex.setSize(pos - poiIndex.getPosition()); } void endPOITypeIndex(int pos) { poiTypeIndex.setSize(pos - poiTypeIndex.getPosition()); } void endZip(int pos) { zip.setSize(pos - zip.getPosition()); } void endHighway(int pos) { highway.setSize(pos - highway.getPosition()); } void endExitFacility(int pos) { exitFacility.setSize(pos - exitFacility.getPosition()); } void endHighwayData(int pos) { highwayData.setSize(pos - highwayData.getPosition()); } public int getNumCities() { return city.getNumItems(); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/POIIndex.java0000644000076400007640000000260111157711542022646 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.trergn.Subdivision; /** * Represent a POI index entry * * @author Mark Burton */ public class POIIndex implements Comparable { private final String name; private final byte poiIndex; private final Subdivision group; private final byte subType; public POIIndex(String name, byte poiIndex, Subdivision group, byte subType) { this.name = name; this.poiIndex = poiIndex; this.group = group; this.subType = subType; } void write(ImgFileWriter writer) { writer.put(poiIndex); writer.putChar((char)group.getNumber()); writer.put(subType); //System.err.println("Writing POI Index " + name + " group = " + group.getNumber()); } public int compareTo(Object o) { return name.compareTo(((POIIndex)o).name); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java0000644000076400007640000000662711034140336022754 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt.app.lbl; import uk.me.parabola.imgfmt.app.CommonHeader; import uk.me.parabola.imgfmt.app.ImgFileReader; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.labelenc.CodeFunctions; /** * The header for the LBL file. * * @author Steve Ratcliffe */ public class LBLHeader extends CommonHeader { public static final int HEADER_LEN = 196; // Other lengths are possible static final int INFO_LEN = 28; private static final char UNK3_REC_LEN = 0; private int labelStart; // Start of labels. private int labelSize; // Size of file. // Code page. private int codePage; // The type of encoding employed. This is not a length. private int encodingType = CodeFunctions.ENCODING_FORMAT6; // The label section also contains all kinds of records related to place, // so these have all been put in their own class. private final PlacesHeader placeHeader; public LBLHeader() { super(HEADER_LEN, "GARMIN LBL"); placeHeader = new PlacesHeader(); } /** * Read the rest of the header. Specific to the given file. It is guaranteed * that the file position will be set to the correct place before this is * called. * * @param reader The header is read from here. */ protected void readFileHeader(ImgFileReader reader) { labelStart = reader.getInt(); labelSize = reader.getInt(); reader.get(); encodingType = reader.get(); // Read the places part of the header. placeHeader.readFileHeader(reader); // more to do but not needed yet... Just set position reader.position(labelStart); } /** * Write the rest of the header. It is guaranteed that the writer will be set * to the correct position before calling. * * @param writer The header is written here. */ protected void writeFileHeader(ImgFileWriter writer) { // LBL1 section, these are regular labels writer.putInt(HEADER_LEN + INFO_LEN); writer.putInt(getLabelSize()); writer.put((byte) 0); writer.put((byte) encodingType); placeHeader.writeFileHeader(writer); writer.putChar((char) getCodePage()); //code writer.putInt(0); // Sort descriptor ??? what does that mean writer.putInt(HEADER_LEN); writer.putInt(INFO_LEN); writer.putInt(placeHeader.getLastPos()); writer.putInt(0); writer.putChar(UNK3_REC_LEN); writer.putChar((char) 0); } protected int getEncodingType() { return encodingType; } public void setEncodingType(int type) { this.encodingType = type; } protected int getLabelSize() { return labelSize; } public void setLabelSize(int labelSize) { this.labelSize = labelSize; placeHeader.setLabelEnd(HEADER_LEN + INFO_LEN + labelSize); } protected int getCodePage() { return codePage; } public void setCodePage(int codePage) { this.codePage = codePage; } public int getLabelStart() { return labelStart; } public PlacesHeader getPlaceHeader() { return placeHeader; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java0000644000076400007640000002267611177352240023031 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.lbl; import java.util.List; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.Exit; /** * @author Steve Ratcliffe */ public class POIRecord { class SimpleStreetPhoneNumber // Helper Class to encode Street Phone Numbers { /** Street and Phone numbers can be stored in two different ways in the poi record Simple Number that only contain digits are coded in base 11 coding. This helper class tries to code the given number. If the number contains other chars like in 4a the coding fails and the caller has to use a Label instead */ private byte[] encodedNumber; private int encodedSize; public boolean set(String number) { int i = 0; int j = 0; int val = 0; // remove sourounding whitespaces to increase chance for simple encoding number = number.trim(); encodedNumber = new byte[(number.length()/2)+2]; while(i < number.length()) { int c1; int c2; c1 = decodeChar(number.charAt(i)); i++; if(i < number.length()) { c2 = decodeChar(number.charAt(i)); i++; } else c2 = 10; if(c1 < 0 || c1 > 10 || c2 < 0 || c2 > 10) // Only 0-9 and - allowed { return false; } val = c1 * 11 + c2; // Encode as base 11 if(i < 3 || i >= number.length()) // first byte needs special marking with 0x80 val |= 0x80; // If this is not set would be treated as label pointer encodedNumber[j++] = (byte)val; } if((val & 0x80) == 0 || i < 3) // terminate string with 0x80 if not done { val = 0xF8; encodedNumber[j++] = (byte)val; } encodedSize = j; return true; } public void write(ImgFileWriter writer) { for(int i = 0; i < encodedSize; i++) writer.put(encodedNumber[i]); } public boolean isUsed() { return (encodedSize > 0); } public int getSize() { return encodedSize; } private int decodeChar(char ch) { return (ch - '0'); } } private static final byte HAS_STREET_NUM = 0x01; private static final byte HAS_STREET = 0x02; private static final byte HAS_CITY = 0x04; private static final byte HAS_ZIP = 0x08; private static final byte HAS_PHONE = 0x10; private static final byte HAS_EXIT = 0x20; private static final byte HAS_TIDE_PREDICTION = 0x40; /* Not used yet private static final AddrAbbr ABBR_HASH = new AddrAbbr(' ', "#"); private static final AddrAbbr ABBR_APARTMENT = new AddrAbbr('1', "APT"); private static final AddrAbbr ABBR_BUILDING = new AddrAbbr('2', "BLDG"); private static final AddrAbbr ABBR_DEPT = new AddrAbbr('3', "DEPT"); private static final AddrAbbr ABBR_FLAT = new AddrAbbr('4', "FL"); private static final AddrAbbr ABBR_ROOM = new AddrAbbr('5', "RM"); private static final AddrAbbr ABBR_STE = new AddrAbbr('6', "STE"); // don't know what this is? private static final AddrAbbr ABBR_UNIT = new AddrAbbr('7', "UNIT"); */ private int offset = -1; private Label poiName; private final SimpleStreetPhoneNumber simpleStreetNumber = new SimpleStreetPhoneNumber(); private final SimpleStreetPhoneNumber simplePhoneNumber = new SimpleStreetPhoneNumber(); private Label streetName; private Label streetNumberName; // Used for numbers such as 221b private Label complexPhoneNumber; // Used for numbers such as 221b private City city; private char zipIndex; private Exit exit; //private String phoneNumber; public void setLabel(Label label) { this.poiName = label; } public void setStreetName(Label label) { this.streetName = label; } public boolean setSimpleStreetNumber(String streetNumber) { return simpleStreetNumber.set(streetNumber); } public void setComplexStreetNumber(Label label) { streetNumberName = label; } public boolean setSimplePhoneNumber(String phone) { return simplePhoneNumber.set(phone); } public void setComplexPhoneNumber(Label label) { complexPhoneNumber = label; } public void setZipIndex(int zipIndex) { this.zipIndex = (char) zipIndex; } public void setCity(City city) { this.city = city; } public void setExit(Exit exit) { this.exit = exit; } void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs, long numCities, long numZips, long numHighways, long numExitFacilities) { assert offset == realofs : "offset = " + offset + " realofs = " + realofs; int ptr = poiName.getOffset(); if (POIGlobalFlags != getPOIFlags()) ptr |= 0x800000; writer.put3(ptr); if (POIGlobalFlags != getPOIFlags()) writer.put(getWrittenPOIFlags(POIGlobalFlags)); if (streetNumberName != null) { int labOff = streetNumberName.getOffset(); writer.put((byte)((labOff & 0x7F0000) >> 16)); writer.putChar((char)(labOff & 0xFFFF)); } else if (simpleStreetNumber.isUsed()) simpleStreetNumber.write(writer); if (streetName != null) writer.put3(streetName.getOffset()); if (city != null) { char cityIndex = (char) city.getIndex(); if(numCities > 255) writer.putChar(cityIndex); else writer.put((byte)cityIndex); } if (zipIndex > 0) { if(numZips > 255) writer.putChar(zipIndex); else writer.put((byte)zipIndex); } if (complexPhoneNumber != null) { int labOff = complexPhoneNumber.getOffset(); writer.put((byte)((labOff & 0x7F0000) >> 16)); writer.putChar((char)(labOff & 0xFFFF)); } else if (simplePhoneNumber.isUsed()) simplePhoneNumber.write(writer); if(exit != null) { Label description = exit.getDescription(); int val = 0; if(description != null) { val = description.getOffset(); assert val < 0x400000 : "Exit description label offset too large"; } if(exit.getOvernightParking()) val |= 0x400000; List facilites = exit.getFacilities(); ExitFacility ef = null; if(facilites.size() > 0) ef = facilites.get(0); if(ef != null) val |= 0x800000; // exit facilites defined writer.put3(val); char highwayIndex = (char)exit.getHighway().getIndex(); if(numHighways > 255) writer.putChar(highwayIndex); else writer.put((byte)highwayIndex); if(ef != null) { char exitFacilityIndex = (char)ef.getIndex(); if(numExitFacilities > 255) writer.putChar(exitFacilityIndex); else writer.put((byte)exitFacilityIndex); } } } byte getPOIFlags() { byte b = 0; if (streetName != null) b |= HAS_STREET; if (simpleStreetNumber.isUsed() || streetNumberName != null) b |= HAS_STREET_NUM; if (city != null) b |= HAS_CITY; if (zipIndex > 0) b |= HAS_ZIP; if (simplePhoneNumber.isUsed() || complexPhoneNumber != null) b |= HAS_PHONE; if (exit != null) b |= HAS_EXIT; return b; } byte getWrittenPOIFlags(byte POIGlobalFlags) { int mask; int flag = 0; int j = 0; int usedFields = getPOIFlags(); /* the local POI flag is really tricky if a bit is not set in the global mask we have to skip this bit in the local mask. In other words the meaning of the local bits change influenced by the global bits */ for(byte i = 0; i < 6; i++) { mask = 1 << i; if((mask & POIGlobalFlags) == mask) { if((mask & usedFields) == mask) flag |= (1 << j); j++; } } flag |= 0x80; // gpsmapedit asserts for this bit set return (byte) flag; } /** * Sets the start offset of this POIRecord * * \return Number of bytes needed by this entry */ int calcOffset(int ofs, byte POIGlobalFlags, long numCities, long numZips, long numHighways, long numExitFacilities) { offset = ofs; int size = 3; if (exit != null) { size += 3; size += (numHighways > 255)? 2 : 1; if(exit.getFacilities().size() > 0) size += (numExitFacilities > 255)? 2 : 1; } if (POIGlobalFlags != getPOIFlags()) size += 1; if (simpleStreetNumber.isUsed()) size += simpleStreetNumber.getSize(); if (streetNumberName != null) size += 3; if (simplePhoneNumber.isUsed()) size += simplePhoneNumber.getSize(); if (complexPhoneNumber != null) size += 3; if (streetName != null) size += 3; if (city != null) { /* depending on how many cities are in the LBL block we have to write one or two bytes */ if(numCities > 255) size += 2; else size += 1; } if (zipIndex > 0) { /* depending on how many zips are in the LBL block we have to write one or two bytes */ if(numZips > 255) size += 2; else size += 1; } return size; } public int getOffset() { if (offset == -1) throw new IllegalStateException("Offset not known yet."); return offset; } /** * Address abbreviations. */ static class AddrAbbr { private final char code; private final String value; AddrAbbr(char code, String value) { this.code = code; this.value = value; } public String toString() { return value; } public char getCode() { return code; } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/ImgFileReader.java0000644000076400007640000000417411054371063023120 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 07-Dec-2006 */ package uk.me.parabola.imgfmt.app; import uk.me.parabola.imgfmt.ReadFailedException; import java.io.IOException; import java.io.Closeable; /** * For reading subfiles from the img. The focus of mkgmap is on writing, * but some limited reading is needed for several operations. * * @author Steve Ratcliffe */ public interface ImgFileReader extends Closeable { /** * Get the position. Needed because may not be reflected in the underlying * file if being buffered. * * @return The logical position within the file. */ public long position(); /** * Set the position of the file. * @param pos The new position in the file. */ void position(long pos); /** * Read in a single byte. * @return The byte that was read. */ public byte get() throws ReadFailedException; /** * Read in two bytes. Done in the correct byte order. * @return The 2 byte integer that was read. */ public char getChar() throws ReadFailedException; /** * Get a 3byte signed quantity. * * @return The value read. * @throws ReadFailedException When the file cannot be read. */ public int get3() throws ReadFailedException; /** * Read in a 4 byte value. * @return A 4 byte integer. */ public int getInt() throws ReadFailedException; /** * Read in an arbitary length sequence of bytes. * * @param len The number of bytes to read. */ public byte[] get(int len) throws ReadFailedException; /** * Read a zero terminated string from the file. * @return A string * @throws ReadFailedException For failures. */ public String getZString() throws ReadFailedException; } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/map/0000755000076400007640000000000011216306457020372 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/map/package.html0000644000076400007640000000025210735217321022646 0ustar stevesteve

Complete maps

A complete map consists of at least a TRE RGN and LBL file. This package holds classes that combine these files into a whole.

mkgmap-r1067/src/uk/me/parabola/imgfmt/app/map/Map.java0000644000076400007640000001766111154060727021763 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 */ package uk.me.parabola.imgfmt.app.map; import uk.me.parabola.imgfmt.FileExistsException; import uk.me.parabola.imgfmt.FileNotWritableException; import uk.me.parabola.imgfmt.FileSystemParam; import uk.me.parabola.imgfmt.app.Area; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.lbl.LBLFile; import uk.me.parabola.imgfmt.app.net.NETFile; import uk.me.parabola.imgfmt.app.net.NODFile; import uk.me.parabola.imgfmt.app.trergn.InternalFiles; import uk.me.parabola.imgfmt.app.trergn.MapObject; import uk.me.parabola.imgfmt.app.trergn.PointOverview; import uk.me.parabola.imgfmt.app.trergn.PolygonOverview; import uk.me.parabola.imgfmt.app.trergn.PolylineOverview; import uk.me.parabola.imgfmt.app.trergn.RGNFile; import uk.me.parabola.imgfmt.app.trergn.Subdivision; import uk.me.parabola.imgfmt.app.trergn.TREFile; import uk.me.parabola.imgfmt.app.trergn.Zoom; import uk.me.parabola.imgfmt.fs.FileSystem; import uk.me.parabola.imgfmt.sys.ImgFS; import uk.me.parabola.log.Logger; import uk.me.parabola.util.Configurable; import uk.me.parabola.util.EnhancedProperties; /** * Holder for a complete map. A map is made up of several files which * include at least the TRE, LBL and RGN files. * * It is the interface for all information about the whole map, such as the * point overviews etc. Subdivision will hold the map elements. * *

Needless to say, it has nothing to do with java.util.Map. * * @author Steve Ratcliffe */ public class Map implements InternalFiles, Configurable { private static final Logger log = Logger.getLogger(Map.class); private String filename; private String mapName; private FileSystem fileSystem; private TREFile treFile; private RGNFile rgnFile; private LBLFile lblFile; private NETFile netFile; private NODFile nodFile; // Use createMap() or loadMap() instead of creating a map directly. private Map() { } /** * Create a complete map. This consists of (at least) three * files that all have the same basename and different extensions. * * @param mapname The name of the map. This is an 8 digit number as a * string. * @param params Parameters that describe the file system that the map * will be created in. * @return A map object that holds together all the files that make it up. * @throws FileExistsException If the file already exists and we do not * want to overwrite it. * @throws FileNotWritableException If the file cannot * be opened for write. */ public static Map createMap(String mapname, FileSystemParam params) throws FileExistsException, FileNotWritableException { Map m = new Map(); m.mapName = mapname; String outFilename = mapname + ".img"; FileSystem fs = ImgFS.createFs(outFilename, params); m.filename = outFilename; m.fileSystem = fs; m.rgnFile = new RGNFile(m.fileSystem.create(mapname + ".RGN")); m.treFile = new TREFile(m.fileSystem.create(mapname + ".TRE"), true); m.lblFile = new LBLFile(m.fileSystem.create(mapname + ".LBL")); int mapid; try { mapid = Integer.parseInt(mapname); } catch (NumberFormatException e) { mapid = 0; } m.treFile.setMapId(mapid); m.fileSystem = fs; return m; } public void config(EnhancedProperties props) { try { if (props.containsKey("route")) { addNet(); addNod(); } else if (props.containsKey("net")) { addNet(); } } catch (FileExistsException e) { log.warn("Could not add NET and/or NOD sections"); } treFile.config(props); } protected void addNet() throws FileExistsException { netFile = new NETFile(fileSystem.create(mapName + ".NET"), true); } protected void addNod() throws FileExistsException { nodFile = new NODFile(fileSystem.create(mapName + ".NOD"), true); } /** * Set the area that the map covers. * @param area The outer bounds of the map. */ public void setBounds(Area area) { treFile.setBounds(area); } /** * Add a copyright message to the map. * @param str the copyright message. The second (last?) one set * gets shown when the device starts (sometimes?). */ public void addCopyright(String str) { Label cpy = lblFile.newLabel(str); treFile.addCopyright(cpy); } /** * There is an area after the TRE header and before its data * starts that can be used to save any old junk it seems. * * @param info Any string. */ public void addInfo(String info) { treFile.addInfo(info); } /** * Create a new zoom level. The level 0 is the most detailed and * level 15 is the most general. Most maps would just have 4 * different levels or less. We are just having two to start with * but will probably advance to at least 3. * * @param level The zoom level, and integer between 0 and 15. Its * like a logical zoom level. * @param bits The number of bits per coordinate, a measure of * the actual amount of detail that will be in the level. So this * is like a physical zoom level. * @return The zoom object. */ public Zoom createZoom(int level, int bits) { return treFile.createZoom(level, bits); } /** * Create the top level division. It must be empty afaik and cover * the whole area of the map. * * @param area The whole map area. * @param zoom The zoom level that you want the top level to be * at. Its going to be at least level 1. * @return The top level division. */ public Subdivision topLevelSubdivision(Area area, Zoom zoom) { zoom.setInherited(true); // May not always be necessary/desired InternalFiles ifiles = this; Subdivision sub = Subdivision.topLevelSubdivision(ifiles, area, zoom); rgnFile.startDivision(sub); return sub; } /** * Create a subdivision that is beneath the top level. We have to * pass the parent division. *

* Note that you cannot create these all up front. You must * create it, fill it will its map elements and then create the * next one. You must also start at the top level and work down. * * @param parent The parent subdivision. * @param area The area of the new child subdiv. * @param zoom The zoom level of the child. * @return The new division. */ public Subdivision createSubdivision(Subdivision parent, Area area, Zoom zoom) { log.debug("creating division"); return parent.createSubdivision(this, area, zoom); } public void addPointOverview(PointOverview ov) { treFile.addPointOverview(ov); } public void addPolylineOverview(PolylineOverview ov) { treFile.addPolylineOverview(ov); } public void addPolygonOverview(PolygonOverview ov) { treFile.addPolygonOverview(ov); } /** * Set the point of interest flags. * @param flags The POI flags. */ public void setPoiDisplayFlags(int flags) { treFile.setPoiDisplayFlags((byte) flags); } public void addMapObject(MapObject item) { rgnFile.addMapObject(item); } public void setLabelCodePage(int cp) { lblFile.setCodePage(cp); } public void setLabelCharset(String desc, boolean forceUpper) { lblFile.setCharacterType(desc, forceUpper); } /** * Close this map by closing all the constituent files. */ public void close() { rgnFile.close(); treFile.close(); lblFile.close(); if (netFile != null) netFile.close(); if (nodFile != null) nodFile.close(); fileSystem.close(); } public String getFilename() { return filename; } public RGNFile getRgnFile() { return rgnFile; } public LBLFile getLblFile() { return lblFile; } public TREFile getTreFile() { return treFile; } public NETFile getNetFile() { return netFile; } public NODFile getNodFile() { return nodFile; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/0000755000076400007640000000000011216306457021362 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/SimpleDecoder.java0000644000076400007640000000225610743733614024754 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 23, 2007 Time: 1:43:07 PM */ package uk.me.parabola.imgfmt.app.labelenc; import java.io.ByteArrayOutputStream; /** * Decodes as as though every byte where a character without any translation. */ public class SimpleDecoder implements CharacterDecoder { private final ByteArrayOutputStream out = new ByteArrayOutputStream(); private boolean needReset; public boolean addByte(int b) { if (b == 0) { needReset = true; return true; } if (needReset) { needReset = false; out.reset(); } out.write(b); return false; } public EncodedText getText() { byte[] ba = out.toByteArray(); return new EncodedText(ba, ba.length); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/EncodedText.java0000644000076400007640000000216610552535157024443 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; /** * Holds the bytes and length of an encoded character string used in a label. * The length of the byte array may be longer than the part that is actually * used, so the length property should always be used. * * Class is imutable. * * @author Steve Ratcliffe */ public class EncodedText { private final byte[] ctext; private final int length; public EncodedText(byte[] buf, int len) { this.ctext = buf; this.length = len; } public byte[] getCtext() { return ctext; } public int getLength() { return length; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/BaseEncoder.java0000644000076400007640000001140411201131262024357 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; import uk.me.parabola.log.Logger; import java.nio.charset.Charset; import java.util.Arrays; import java.util.Formatter; import java.util.Locale; import java.io.InputStream; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; /** * Useful routines for the other encoders. * Provides some default behaviour when a conversion is not possible for * example. * * @author Steve Ratcliffe */ public class BaseEncoder { private static final Logger log = Logger.getLogger(BaseEncoder.class); protected static final EncodedText NO_TEXT = new EncodedText(null, 0); private boolean charsetSupported = true; // Whether to uppercase the labels or not. Default is true because many // GPS devices do not display labels in lower case. private boolean upperCase; private String charset = "ascii"; private static final String[][] rows = new String[256][]; protected boolean isCharsetSupported() { return charsetSupported; } protected void prepareForCharacterSet(String name) { if (Charset.isSupported(name)) { charsetSupported = true; } else { charsetSupported = false; log.warn("requested character set not found " + name); } } protected EncodedText simpleEncode(String text) { if (text == null) return NO_TEXT; char[] in = text.toCharArray(); byte[] out = new byte[in.length + 1]; int off = 0; for (char c : in) out[off++] = (byte) (c & 0xff); return new EncodedText(out, out.length); } protected boolean isUpperCase() { return upperCase; } public void setUpperCase(boolean upperCase) { this.upperCase = upperCase; } /** * Convert a string into a string that uses only ascii characters. * * @param s The original string. It can use any unicode character. * @return A string that uses only ascii characters that is a transcription * or transliteration of the original string. */ protected char[] transliterate(String s) { StringBuilder sb = new StringBuilder(s.length() + 5); for (char c : s.toCharArray()) { if (c < 0x80) { sb.append(c); } else { int row = c >>> 8; String[] rowmap = rows[row]; if (rowmap == null) rowmap = loadRow(row); //log.debug("char", Integer.toHexString(c), rowmap[c & 0xff]); sb.append(rowmap[c & 0xff]); } } return sb.toString().toCharArray(); } /** * Load one row of characters. This means unicode characters that are * of the form U+RRXX where RR is the row. * @param row Row number 0-255. * @return An array of strings, one for each character in the row. If there * is no ascii representation then a '?' character will fill that * position. */ private String[] loadRow(int row) { if (rows[row] != null) return rows[row]; String[] newRow = new String[256]; rows[row] = newRow; // Default all to a question mark Arrays.fill(newRow, "?"); charset = "ascii"; StringBuilder name = new StringBuilder(); Formatter fmt = new Formatter(name); fmt.format("/chars/%s/row%02d.trans", charset, row); log.debug("getting file name", name); InputStream is = getClass().getResourceAsStream(name.toString()); try { readCharFile(is, newRow); } catch (IOException e) { log.error("Could not read character translation table"); } return newRow; } /** * Read in a character translit file. Not all code points need to * be defined inside the file. Anything that is left out will become * a question mark. * * @param is The open file to be read. * @param newRow The row that we fill in with strings. */ private void readCharFile(InputStream is, String[] newRow) throws IOException { if (is == null) return; BufferedReader br = new BufferedReader(new InputStreamReader(is, "ascii")); String line; while ((line = br.readLine()) != null) { line = line.trim(); if (line.length() == 0 || line.charAt(0) == '#') continue; String[] fields = line.split("\\s+"); String upoint = fields[0]; String translation = fields[1]; if (upoint.length() != 6 || upoint.charAt(0) != 'U') continue; // The first field must look like 'U+RRXX', we extract the XX part int index = Integer.parseInt(upoint.substring(4), 16); newRow[index] = translation.toUpperCase(Locale.ENGLISH); } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/CharacterEncoder.java0000644000076400007640000000236110552527564025431 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; /** * Interface for encoding characters for use in the Label section of a .img * file. * * Older units are only able to display uppercase ascii characters. Newer ones * can also display latin1 characters and perhaps lowercase too. I believe * that it is possible to buy Japanese units that display Japanese characters * too. * * So we need different implementations to deal with all this. It is made * harder because the possibilities are not known. Many experimental * implementations may be needed before settling on a good one. * * @author Steve Ratcliffe */ public interface CharacterEncoder { public EncodedText encodeText(String text); } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/Utf8Encoder.java0000644000076400007640000000274510766754612024374 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Feb 19, 2008 */ package uk.me.parabola.imgfmt.app.labelenc; import java.io.UnsupportedEncodingException; import java.util.Locale; /** * Ecoder for labels in utf-8, note that I am not actually sure that this * is in fact used anywhere. * * @author Steve Ratcliffe */ public class Utf8Encoder extends BaseEncoder implements CharacterEncoder { public EncodedText encodeText(String text) { if (text == null) return NO_TEXT; String uctext; if (isUpperCase()) uctext = text.toUpperCase(Locale.ENGLISH); else uctext = text; EncodedText et; try { byte[] buf = uctext.getBytes("utf-8"); byte[] res = new byte[buf.length + 1]; System.arraycopy(buf, 0, res, 0, buf.length); res[buf.length] = 0; et = new EncodedText(res, res.length); } catch (UnsupportedEncodingException e) { // As utf-8 must be supported, this can't happen byte[] buf = uctext.getBytes(); et = new EncodedText(buf, buf.length); } return et; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/TableCreator.java0000644000076400007640000000356010716437006024577 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 04-Nov-2007 */ package uk.me.parabola.imgfmt.app.labelenc; import java.io.PrintStream; /** * Call this with a unicode row number and it will produce an empty table * that can be modified. * * @author Steve Ratcliffe */ public class TableCreator { public static void main(String[] args) { int row = Integer.parseInt(args[0]); PrintStream out = System.out; out.println(""); out.println("# This is table for transliterating characters in the range"); out.format( "# from U+%02x00 to U+%02xff\n", row, row); out.println("#"); out.println("# The first column is the unicode character and the second"); out.println("# column is the transliteration of that character to ascii characters."); out.println("# One or more characters can be used, for example for a character æ which"); out.println("# is a combined a and e you could write 'ae' (without the quotes) as the "); out.println("# transliteration."); out.println("#"); out.println("# There are languages where this will not work very well, in case"); out.println("# another approach should be tried."); out.println("#"); out.println("# Any line can be deleted and will default to a '?' character"); out.println("#"); out.println(""); for (int i = 0; i < 256; i++) { out.format("U+%02x%02x ? # character %c\n", row, i, (char) (row*256+i)); } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/CharacterDecoder.java0000644000076400007640000000315710735220743025413 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; /** * Interface for decoding characters for use in the Label section of a .img * file. * * These things are stateful, you add bytes read from the file to them and * they return a status when a complete label has been obtained. At this point * you retrieve the text. * * @author Steve Ratcliffe */ public interface CharacterDecoder { /** * Add a byte to this decoder. This will be saved until a complete * label string has been detected. * * @param b The byte read from the lbl file. * @return True if a label string is finished and is ready to be retrieved * via the {@link #getText} method. */ public boolean addByte(int b); /** * Get the valid text. This is guaranteed to be encoded as utf-8. * * @return The byte array and length as an EncodedText struct. */ public EncodedText getText(); /** * Resets the state. This should be called for example if the reader is * jumping to a new place in the file and cannot guarantee that the * previous label was fully read. */ //public void reset(); }mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java0000644000076400007640000000313610735217321025565 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 31-Oct-2007 */ package uk.me.parabola.imgfmt.app.labelenc; import java.io.UnsupportedEncodingException; import java.util.Locale; /** * Convert text to a specified charset. This is used when you give a * charset name on the command line to convert to. * * @author Steve Ratcliffe */ public class AnyCharsetEncoder extends BaseEncoder implements CharacterEncoder { private final String charSet; public AnyCharsetEncoder(String cs) { prepareForCharacterSet(cs); charSet = cs; } public EncodedText encodeText(String text) { if (text == null) return NO_TEXT; if (!isCharsetSupported()) return simpleEncode(text); String ucText; if (isUpperCase()) ucText = text.toUpperCase(Locale.ENGLISH); else ucText = text; try { byte[] bytes = ucText.getBytes(charSet); byte[] res = new byte[bytes.length + 1]; System.arraycopy(bytes, 0, res, 0, bytes.length); return new EncodedText(res, res.length); } catch (UnsupportedEncodingException e) { // This can't really happen as we have already checked. return simpleEncode(text); } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/package.html0000644000076400007640000000025310637204532023640 0ustar stevesteve

Label encoding routines

This package holds routines that encode the labels in the LBL section. There are both useful and experimental schemes here. mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java0000644000076400007640000000271010766754612025042 0ustar stevestevepackage uk.me.parabola.imgfmt.app.labelenc; import java.io.ByteArrayOutputStream; /** * Convert the 6-bit label format back to a java string. */ public class Format6Decoder implements CharacterDecoder { private final ByteArrayOutputStream out = new ByteArrayOutputStream(); private boolean needReset; private boolean symbol; private short store; private int offset = -6; public boolean addByte(int in) { int b = 0xff & in; //wipe out high bits (in case of negative byte) if (needReset) { needReset = false; out.reset(); store = 0; offset = -6; } store <<= 8; store |= b; offset += 8; addChar((store >> offset) & 0x3f); offset -= 6; if (offset >= 0 && !needReset) { addChar((store >> offset) & 0x3f); offset -= 6; } return needReset; } private void addChar(int b) { if (b > 0x2f) { needReset = true; return; } char c; if (symbol) { symbol = false; c = Format6Encoder.SYMBOLS.charAt(b); } else { switch(b) { case 0x1B: // perhaps this is "next-char lower case"? return; case 0x1C: // next char is symbol symbol = true; return; case 0x1D: case 0x1E: case 0x1F: // these define abbreviations; fall through to // lookup which returns a space default: c = Format6Encoder.LETTERS.charAt(b); } } out.write(c); } public EncodedText getText() { byte[] ba = out.toByteArray(); return new EncodedText(ba, ba.length); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/Simple8Encoder.java0000644000076400007640000000166410552527564025063 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; /** * An encoder that just takes the lower 8 bits of the char and uses that * without any character set conversion. Useful for testing mainly (only?). * * @author Steve Ratcliffe */ public class Simple8Encoder extends BaseEncoder implements CharacterEncoder { public EncodedText encodeText(String text) { return simpleEncode(text); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/Utf8Decoder.java0000644000076400007640000000321711110054726024334 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Feb 19, 2008 */ package uk.me.parabola.imgfmt.app.labelenc; import java.io.ByteArrayOutputStream; /** * Decoder for labels in utf-8, note that I am not actually sure that this * is in fact used anywhere. * * @author Steve Ratcliffe */ public class Utf8Decoder implements CharacterDecoder { private final ByteArrayOutputStream out = new ByteArrayOutputStream(); private boolean needreset; /** * Add a byte to this decoder. This will be saved until a complete * label string has been detected. * * @param b The byte read from the lbl file. * @return True if a label string is finished and is ready to be retrieved * via the {@link #getText} method. */ public boolean addByte(int b) { if (b == 0) { needreset = true; out.write(0); return true; } if (needreset) { out.reset(); needreset = true; } out.write(b); return false; } /** * Get the valid text. This is guaranteed to be encoded as utf-8. * * @return The byte array and length as an EncodedText struct. */ public EncodedText getText() { byte[] ba = out.toByteArray(); return new EncodedText(ba, ba.length); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/CodeFunctions.java0000644000076400007640000001050411174626771024777 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app.labelenc; /** * @author Steve Ratcliffe */ public class CodeFunctions { // Label encoding length public static final int ENCODING_FORMAT6 = 6; private static final int ENCODING_FORMAT9 = 9; private static final int ENCODING_FORMAT10 = 10; private int codepage; private int encodingType; private CharacterEncoder encoder; private CharacterDecoder decoder; protected void setEncoder(CharacterEncoder encoder) { this.encoder = encoder; } public CharacterEncoder getEncoder() { return encoder; } protected void setDecoder(CharacterDecoder decoder) { this.decoder = decoder; } public CharacterDecoder getDecoder() { return decoder; } public int getEncodingType() { return encodingType; } protected void setEncodingType(int encodingType) { this.encodingType = encodingType; } public int getCodepage() { return codepage; } public void setCodepage(int codepage) { this.codepage = codepage; } /** * Create a CharacterEncoder for the given charset option. Note that this * routine also writes to the lblHeader parameter to set the encoding type. * @param charset The mkgmap command line option to be interpreted. * @return The various character set parameters that will be needed. */ public static CodeFunctions createEncoderForLBL(String charset) { CodeFunctions funcs = new CodeFunctions(); if ("ascii".equals(charset)) { funcs.setEncodingType(ENCODING_FORMAT6); funcs.setEncoder(new Format6Encoder()); funcs.setDecoder(new Format6Decoder()); } else if ("latin1".equals(charset)) { funcs.setEncodingType(ENCODING_FORMAT9); funcs.setEncoder(new AnyCharsetEncoder("cp1252")); funcs.setCodepage(1252); } else if ("unicode".equals(charset)) { funcs.setEncodingType(ENCODING_FORMAT10); funcs.setEncoder(new Utf8Encoder()); funcs.setDecoder(new Utf8Decoder()); } else if ("simple8".equals(charset)) { funcs.setEncodingType(ENCODING_FORMAT9); funcs.setEncoder(new Simple8Encoder()); } else { funcs.setEncodingType(ENCODING_FORMAT9); funcs.setEncoder(new AnyCharsetEncoder(charset)); guessCodepage(funcs, charset); } return funcs; } /** * Guess the code page from the given charset. Only works with things * like cp1252, windows-1252 and some well known ones. * @param funcs The code page functions. * @param charset The charset that was given. */ private static void guessCodepage(CodeFunctions funcs, String charset) { String cs = charset.toLowerCase(); if (cs.startsWith("cp")) { try { funcs.setCodepage(Integer.parseInt(charset.substring(2))); } catch (NumberFormatException e) { // wasn't in the right form } } else if (cs.startsWith("windows-")) { try { funcs.setCodepage(Integer.parseInt(charset.substring(8))); } catch (NumberFormatException e) { // wasn't in the right form to guess } } else if (cs.equals("latin1")) { funcs.setCodepage(1252); } } /** * Sets encoding functions for a given format and code page. This is used * when reading from an existing file. * * @param format The format from the lbl header. * @return The various character set parameters that will be needed. */ public static CodeFunctions createEncoderForLBL(int format) { CodeFunctions funcs = new CodeFunctions(); if (format == ENCODING_FORMAT6) { funcs.setEncodingType(ENCODING_FORMAT6); funcs.setEncoder(new Format6Encoder()); funcs.setDecoder(new Format6Decoder()); } else { // TODO TEMP... funcs.setEncodingType(ENCODING_FORMAT9); funcs.setEncoder(new AnyCharsetEncoder("cp1252")); funcs.setDecoder(new SimpleDecoder()); } return funcs; } public static CharacterEncoder getDefaultEncoder() { return new Format6Encoder(); } public static CharacterDecoder getDefaultDecoder() { return new Format6Decoder(); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/labelenc/Format6Encoder.java0000644000076400007640000001017111177344016025042 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Jan-2007 */ package uk.me.parabola.imgfmt.app.labelenc; import java.util.Locale; import uk.me.parabola.log.Logger; /** * Format according to the '6 bit' .img format. The text is first upper * cased. Any letter with a diacritic or accent is replaced with its base * letter. * * For example Körnerstraße would become KORNERSTRASSE, * Řípovská would become RIPOVSKA etc. * * I believe that some Garmin units are only capable of showing uppercase * ascii characters, so this will be the default. * * @author Steve Ratcliffe * @see Garmin IMG File Format */ public class Format6Encoder extends BaseEncoder implements CharacterEncoder { private static final Logger log = Logger.getLogger(Format6Encoder.class); // This is 0x1b is the source document, but the accompianing code uses // the value 0x1c, which seems to work. private static final int SYMBOL_SHIFT = 0x1c; public static final String LETTERS = " ABCDEFGHIJKLMNO" + // 0x00-0x0F "PQRSTUVWXYZxx " + // 0x10-0x1F "0123456789xxxxxx"; // 0x20-0x2F public static final String SYMBOLS = "@!\"#$%&'()*+,-./" + // 0x00-0x0F "xxxxxxxxxx:;<=>?" + // 0x10-0x1F "xxxxxxxxxxx[\\]^_"; // 0x20-0x2F /** * Encode the text into the 6 bit format. See the class level notes. * * @param text The original text, which can contain non-ascii characters. * @return Encoded form of the text. Only uppercase ascii characters and * some escape sequences will be present. */ public EncodedText encodeText(String text) { if (text == null || text.length() == 0) return NO_TEXT; String s = text.toUpperCase(Locale.ENGLISH); byte[] buf = new byte[2 * s.length() + 1]; int off = 0; for (char c : transliterate(s)) { if (c == ' ') { buf = put6(buf, off++, 0); } else if (c >= 'A' && c <= 'Z') { buf = put6(buf, off++, c - 'A' + 1); } else if (c >= '0' && c <= '9') { buf = put6(buf, off++, c - '0' + 0x20); } else if (c >= 0x1d && c <= 0x1f) { put6(buf, off++, c); } else { off = shiftedSymbol(buf, off, c); } } buf = put6(buf, off++, 0xff); int len = ((off - 1) * 6) / 8 + 1; return new EncodedText(buf, len); } /** * Certain characters have to be represented by two 6byte quantities. This * routine sorts these out. * * @param buf The buffer to write into. * @param startOffset The offset to start writing to in the output buffer. * @param c The character that we are decoding. * @return The final offset. This will be unchanged if there was nothing * writen because the character does not have any representation. */ private int shiftedSymbol(byte[] buf, int startOffset, char c) { int off = startOffset; int ind = SYMBOLS.indexOf(c); if (ind >= 0) { put6(buf, off++, SYMBOL_SHIFT); put6(buf, off++, ind); } return off; } /** * Each character is packed into 6 bits. This keeps track of everything so * that the character can be put into the right place in the byte array. * * @param buf The buffer to populate. * @param off The character offset, that is the number of the six bit * character. * @param c The character to place. */ private byte[] put6(byte[] buf, int off, int c) { int bitOff = off * 6; // The byte offset int byteOff = bitOff/8; // The offset within the byte int shift = bitOff - 8*byteOff; int mask = 0xfc >> shift; buf[byteOff] |= ((c << 2) >> shift) & mask; // IF the shift is greater than two we have to put the rest in the // next byte. if (shift > 2) { mask = 0xfc << (8 - shift); buf[byteOff + 1] = (byte) (((c << 2) << (8 - shift)) & mask); } return buf; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/BitWriter.java0000644000076400007640000000735611105666203022401 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 14-Dec-2006 */ package uk.me.parabola.imgfmt.app; import uk.me.parabola.log.Logger; /** * A class to write the bitstream. * * @author Steve Ratcliffe */ public class BitWriter { private static final Logger log = Logger.getLogger(BitWriter.class); // Choose so that most roads will not fill it. private static final int INITIAL_BUF_SIZE = 20; // The byte buffer and its current length (allocated length) private byte[] buf; // The buffer private int bufsize; // The allocated size private int buflen; // The actual used length // The bit offset into the byte array. private int bitoff; private static final int BUFSIZE_INC = 50; public BitWriter() { bufsize = INITIAL_BUF_SIZE; buf = new byte[bufsize]; } /** * Put exactly one bit into the buffer. * * @param b The bottom bit of the integer is set at the current bit position. */ private void put1(int b) { ensureSize(bitoff + 1); int off = getByteOffset(bitoff); // Get the remaining bits into the byte. int rem = bitoff - 8 * off; // Or it in, we are assuming that the position is never turned back. buf[off] |= (b & 0x1) << rem; // Increment position bitoff++; // If we are in a new byte, increase the byte length. if ((bitoff & 0x7) == 1) buflen++; debugPrint(b, 1); } public void put1(boolean b) { put1(b ? 1 : 0); } /** * Put a number of bits into the buffer, growing it if necessary. * * @param bval The bits to add, the lowest n bits will be added to * the buffer. * @param nb The number of bits. */ public void putn(int bval, int nb) { int val = bval & ((1<= 24) throw new IllegalArgumentException(); ensureSize(bitoff + n); // Get each affected byte and set bits into it until we are done. while (n > 0) { int ind = getByteOffset(bitoff); int rem = bitoff - 8*ind; buf[ind] |= ((val << rem) & 0xff); // Shift down in preparation for next byte. val >>>= 8-rem; // Account for change so far int nput = 8 - rem; if (nput > n) nput = n; bitoff += nput; n -= nput; } buflen = (bitoff+7)/8; //debugPrint(bval, nb); } public byte[] getBytes() { return buf; } public int getLength() { return buflen; } /** * Get the byte offset for the given bit number. * * @param boff The number of the bit in question. * @return The index into the byte array where the bit resides. */ private int getByteOffset(int boff) { return boff/8; } /** * Set everything up so that the given size can be accomodated. * The buffer is resized if necessary. * * @param newlen The new length of the bit buffer in bits. */ private void ensureSize(int newlen) { if (newlen/8 >= bufsize) reallocBuffer(); } /** * Reallocate the byte buffer. */ private void reallocBuffer() { log.debug("reallocating buffer"); bufsize += BUFSIZE_INC; byte[] newbuf = new byte[bufsize]; System.arraycopy(this.buf, 0, newbuf, 0, this.buf.length); this.buf = newbuf; } private void debugPrint(int b, int i) { if (log.isDebugEnabled()) log.debug("after put", i, "of", b, " bufsize=", bufsize, ", len=", buflen, ", pos=", bitoff); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/Coord.java0000644000076400007640000001234411210173232021515 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 11-Dec-2006 */ package uk.me.parabola.imgfmt.app; import java.util.Formatter; import uk.me.parabola.imgfmt.Utils; /** * A point coordinate in unshifted map-units. * A map unit is 360/2^24 degrees. In some places shifted coordinates * are used, which means that they are divided by some power of two to save * space in the file. * * You can create one of these with lat/long by calling the constructor with * double args. * * This is an immutable class. * * @author Steve Ratcliffe */ public class Coord implements Comparable { private final int latitude; private final int longitude; private int highwayCount; // number of highways that use this point /** * Construct from co-ordinates that are already in map-units. * @param latitude The latitude in map units. * @param longitude The longitude in map units. */ public Coord(int latitude, int longitude) { this.latitude = latitude; this.longitude = longitude; } /** * Construct from regular latitude and longitude. * @param latitude The latitude in degrees. * @param longitude The longitude in degrees. */ public Coord(double latitude, double longitude) { this.latitude = Utils.toMapUnit(latitude); this.longitude = Utils.toMapUnit(longitude); } public int getLatitude() { return latitude; } public int getLongitude() { return longitude; } public long getId() { return 0; } public int getHighwayCount() { return highwayCount; } public void incHighwayCount() { ++highwayCount; } public int hashCode() { return latitude+longitude; } public boolean equals(Object obj) { if (obj == null) return false; if (obj.getClass() != getClass()) return false; Coord other = (Coord) obj; return latitude == other.latitude && longitude == other.longitude; } /** * Distance to other point in meters. */ public double distance(Coord other) { return quickDistance(other); } public double slowDistance(Coord other) { if (equals(other)) return 0; double lat1 = Utils.toRadians(latitude); double lat2 = Utils.toRadians(other.getLatitude()); double lon1 = Utils.toRadians(getLongitude()); double lon2 = Utils.toRadians(other.getLongitude()); double R = 6371000; // meters // cosine of great circle angle between points double cangle = Math.sin(lat1)*Math.sin(lat2) + Math.cos(lat1)*Math.cos(lat2) * Math.cos(lon2-lon1); return Math.acos(cangle) * R; } public double quickDistance(Coord other){ double qd = 40075000 * Math.sqrt(distanceInDegreesSquared(other)) / 360; final boolean testing = false; if(testing) { double sd = slowDistance(other); double delta = Math.abs(qd - sd); if(delta > sd / 500) System.err.println("quickDistance() = " + qd + " slowDistance() = " + sd + " (" + (100 * delta / sd) + "% difference)"); } return qd; } public double distanceInDegreesSquared(Coord other) { if (equals(other)) return 0; double lat1 = Utils.toDegrees(getLatitude()); double lat2 = Utils.toDegrees(other.getLatitude()); double long1 = Utils.toDegrees(getLongitude()); double long2 = Utils.toDegrees(other.getLongitude()); double latDiff; if (lat1 < lat2) latDiff = lat2 - lat1; else latDiff = lat1 - lat2; if (latDiff > 90) latDiff -= 180; double longDiff; if (long1 < long2) longDiff = long2 - long1; else longDiff = long1 - long2; if (longDiff > 180) longDiff -= 360; // scale longDiff by cosine of average latitude longDiff *= Math.cos(Math.PI / 180 * Math.abs((lat1 + lat2) / 2)); return (latDiff * latDiff) + (longDiff * longDiff); } public Coord makeBetweenPoint(Coord other, double fraction) { return new Coord((int)(latitude + (other.latitude - latitude) * fraction), (int)(longitude + (other.longitude - longitude) * fraction)); } /** * Sort lexicographically by longitude, then latitude. * * This ordering is used for sorting entries in NOD3. */ public int compareTo(Coord other) { int clon = longitude - other.getLongitude(); if (clon == 0) return latitude - other.getLatitude(); else return clon; } /** * Returns a string representation of the object. * * @return a string representation of the object. */ public String toString() { return (latitude) + "/" + (longitude); } public String toDegreeString() { Formatter fmt = new Formatter(); return fmt.format("%.5f/%.5f", Utils.toDegrees(latitude), Utils.toDegrees(longitude)).toString(); } public String toOSMURL(int zoom) { return ("http://www.openstreetmap.org/?lat=" + new Formatter().format("%.5f", Utils.toDegrees(latitude)) + "&lon=" + new Formatter().format("%.5f", Utils.toDegrees(longitude)) + "&zoom=" + zoom); } public String toOSMURL() { return toOSMURL(17); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/BitReader.java0000644000076400007640000000355711136167455022337 0ustar stevesteve/* * Copyright (C) 2008 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 29-Aug-2008 */ package uk.me.parabola.imgfmt.app; /** * @author Steve Ratcliffe */ public class BitReader { private final byte[] buf; private int bitPosition; public BitReader(byte[] buf) { this.buf = buf; } public boolean get1() { int off = bitPosition % 8; byte b = buf[bitPosition / 8]; bitPosition++; return ((b >> off) & 1) == 1; } public int get(int n) { int res = 0; int pos = 0; while (pos < n) { int index = bitPosition / 8; int off = bitPosition % 8; byte b = buf[index]; b >>= off; int nbits = n - pos; if (nbits > (8-off)) nbits = 8 - off; int mask = ((1 << nbits) - 1); res |= ((b & mask) << pos); pos += nbits; bitPosition += nbits; } return res; } /** * Get a signed n-bit value, treating 1 << (n-1) as a * flag to read another signed n-bit value for extended * range (mysteriously only in the negative direction). * * At least two levels of recursion show up in the wild; * current code computes correctly in that example. */ public int sget2(int n) { int res = get(n); int top = 1 << (n - 1); if ((res & top) != 0) { int mask = top - 1; if ((res & mask) == 0) { int res2 = sget2(n); res = (~mask | res) + 1 + res2; } else { res = ~mask | res; } } return res; } public int getBitPosition() { return bitPosition; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/0000755000076400007640000000000011216306457020431 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/BitmapImage.java0000644000076400007640000000675311115044052023452 0ustar stevestevepackage uk.me.parabola.imgfmt.app.typ; import java.util.Comparator; import java.util.Map; import uk.me.parabola.imgfmt.FormatException; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Writeable; import uk.me.parabola.log.Logger; public class BitmapImage implements Writeable, Comparator { private static final Logger log = Logger.getLogger(BitmapImage.class); private int off; private byte dayNight; // 7=Night 1=Day private byte width; private byte height; private String image; private byte typ; private int cpc; private byte subtype; private Map colors; public final byte getTyp() { return typ; } public final byte getSubtype() { return subtype; } private BitmapImage() { /*for compare*/ } protected static BitmapImage comperator() { return new BitmapImage(); } public BitmapImage(byte typ, byte subtype, byte dayNight, int width, Map colours, int cpc, String image) { if (image == null) throw new FormatException("NULL Image"); height = (byte) (image.length() / width); colors = colours; if (width != 16) throw new FormatException("Only 16 pixel with supported"); if (height * width != image.length()) throw new FormatException("Only 16 pixel with supported"); this.cpc = cpc; this.dayNight = dayNight; this.width = (byte) width; this.image = image; this.typ = typ; this.subtype = subtype; } public void write(ImgFileWriter writer) { off = writer.position(); byte cc = (byte) (colors.size()); // We only Support up to 16 Colors(currently) writer.put(dayNight); writer.put(width); writer.put(height); writer.put(cc); writer.put((byte) 0x10); // 0x10 => 888 (8Bits per Color) // 0x20 => 444 (4Bits per Color) int cid = 0; for (Rgb rgb : colors.values()) { rgb.write(writer, (byte) 0x10); rgb.setIdx(cid++); } int idx = 0; try { if (cc <= 16) { for (idx = 0; idx < image.length(); idx += 2 * cpc) { int p2 = colors.get(image.substring(idx, idx + cpc)).getIdx(); int p1 = colors.get(image.substring(idx + 1, idx + 1 + cpc)).getIdx(); if (p1 == -1 || p2 == -1) throw new FormatException("Invalid Color Code"); byte p = (byte) (p1 << 4 | p2); writer.put(p); } } else { for (idx = 0; idx < image.length(); idx += 2) { int p = colors.get(image.substring(idx, idx + cpc)).getIdx(); if (p == -1) throw new FormatException("Invalid Color Code"); writer.put((byte) p); } } } catch (Throwable ex) { log.error(ex.getMessage(), ex); for (Map.Entry e : colors.entrySet()) log.info("'" + e.getKey() + "' c rgb(" + e.getValue().r + " , " + e .getValue().g + " , " + e.getValue().b + ")"); log.info("bild[idx+0]='" + image .substring(idx, idx + cpc) + "' => " + colors .get(image.substring(idx, idx + cpc))); log.info(new StringBuilder().append("bild[idx+1]='").append(image .substring(idx, idx + 1 + cpc)).append("' => ").append(colors .get(image.substring(idx, idx + 1 + cpc))).toString()); } // TODO String with names } public int getOffset() { return off - TYPHeader.HEADER_LEN; } public int getSize() { return 5 + colors.size() * 3 + width * height / 2; } public int compare(BitmapImage a, BitmapImage b) { if (a == null) return 1; if (b == null) return -1; if (a.typ < b.typ) return -1; if (a.typ > b.typ) return 1; if (a.dayNight < b.dayNight) return -1; if (a.dayNight > b.dayNight) return 1; return 0; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/DrawOrder.java0000644000076400007640000000074611114503661023165 0ustar stevestevepackage uk.me.parabola.imgfmt.app.typ; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Writeable; public class DrawOrder implements Writeable { private final char typ; private final char unk1; private final byte unk2; public DrawOrder(char typ, char unk1, byte unk2) { this.typ = typ; this.unk1 = unk1; this.unk2 = unk2; } public void write(ImgFileWriter writer) { writer.putChar(typ); writer.putChar(unk1); writer.put(unk2); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/package.html0000644000076400007640000000037710735217321022715 0ustar stevesteve

The TYP file for custom rendering styles

This file contains definitions of how a map element will be rendered on the GPS which allows you to display things in a different way. Not all devices support the TYP file however.

mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/TYPHeader.java0000644000076400007640000001052211114503661023052 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt.app.typ; import uk.me.parabola.imgfmt.app.CommonHeader; import uk.me.parabola.imgfmt.app.ImgFileReader; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Section; /** * The header for the TYP file. * * @author Thomas Lußnig */ public class TYPHeader extends CommonHeader { public static final int HEADER_LEN = 91; // 0x5b private char familyId; private char productId; private char codePage; private final Section pointData = new Section(); private final Section lineData = new Section(pointData); private final Section polygonData = new Section(lineData); private final Section pointIndex = new Section(polygonData, (char) 4); private final Section lineIndex = new Section(pointIndex, (char) 3); private final Section polygonIndex = new Section(lineIndex, (char) 3); private final Section shapeStacking = new Section(polygonIndex, (char) 5); public TYPHeader() { super(HEADER_LEN, "GARMIN TYP"); } /** * Read the rest of the header. Specific to the given file. It is guaranteed * that the file position will be set to the correct place before this is * called. * * @param reader The header is read from here. */ protected void readFileHeader(ImgFileReader reader) { // Reset position for the real header reading code. reader.position(COMMON_HEADER_LEN); codePage = reader.getChar(); // 1252 pointData.setPosition(reader.getInt()); pointData.setSize(reader.getInt()); lineData.setPosition(reader.getInt()); lineData.setSize(reader.getInt()); polygonData.setPosition(reader.getInt()); polygonData.setSize(reader.getInt()); familyId = reader.getChar(); productId = reader.getChar(); pointIndex.setPosition(reader.getInt()); pointIndex.setItemSize(reader.getChar()); pointIndex.setSize(reader.getInt()); lineIndex.setPosition(reader.getInt()); lineIndex.setItemSize(reader.getChar()); lineIndex.setSize(reader.getInt()); polygonIndex.setPosition(reader.getInt()); polygonIndex.setItemSize(reader.getChar()); polygonIndex.setSize(reader.getInt()); shapeStacking.setPosition(reader.getInt()); shapeStacking.setItemSize(reader.getChar()); shapeStacking.setSize(reader.getInt()); } /** * Write the rest of the header. It is guaranteed that the writer will be set * to the correct position before calling. * * @param writer The header is written here. */ protected void writeFileHeader(ImgFileWriter writer) { System.out.println("in file header write"); writer.putChar(codePage); writer.putInt(pointData.getPosition()); writer.putInt(pointData.getSize()); writer.putInt(lineData.getPosition()); writer.putInt(lineData.getSize()); writer.putInt(polygonData.getPosition()); writer.putInt(polygonData.getSize()); writer.putChar(familyId); writer.putChar(productId); writer.putInt(pointIndex.getPosition()); writer.putChar(pointIndex.getItemSize()); writer.putInt(pointIndex.getSize()); writer.putInt(lineIndex.getPosition()); writer.putChar(lineIndex.getItemSize()); writer.putInt(lineIndex.getSize()); writer.putInt(polygonIndex.getPosition()); writer.putChar(polygonIndex.getItemSize()); writer.putInt(polygonIndex.getSize()); writer.putInt(shapeStacking.getPosition()); writer.putChar(shapeStacking.getItemSize()); writer.putInt(shapeStacking.getSize()); } char getCodePage() { return codePage; } void setCodePage(char codePage) { this.codePage = codePage; } Section getPointData() { return pointData; } char getFamilyId() { return familyId; } void setFamilyId(char familyId) { this.familyId = familyId; } char getProductId() { return productId; } void setProductId(char productId) { this.productId = productId; } Section getPointIndex() { return pointIndex; } Section getShapeStacking() { return shapeStacking; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/TYPFile.java0000644000076400007640000001034111114503661022540 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 * Change: Thomas Lußnig */ package uk.me.parabola.imgfmt.app.typ; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import uk.me.parabola.imgfmt.app.BufferedImgFileReader; import uk.me.parabola.imgfmt.app.BufferedImgFileWriter; import uk.me.parabola.imgfmt.app.ImgFile; import uk.me.parabola.imgfmt.app.Writeable; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * The TYP file. * * @author Thomas Lußnig */ public class TYPFile extends ImgFile { private static final Logger log = Logger.getLogger(TYPFile.class); private final TYPHeader header = new TYPHeader(); private final List images = new LinkedList(); private final List pointInfo = new LinkedList(); private final List drawOrder = new LinkedList(); public TYPFile(ImgChannel chan, boolean write) { setHeader(header); if (write) { setWriter(new BufferedImgFileWriter(chan)); position(TYPHeader.HEADER_LEN); } else { setReader(new BufferedImgFileReader(chan)); header.readHeader(getReader()); } } public void setCodePage(char code) { header.setCodePage(code); } public void setFamilyId(char code) { header.setFamilyId(code); } public void setProductId(char code) { header.setProductId(code); } public void write() { // HEADER_LEN => 1. Image Collections.sort(images, BitmapImage.comperator()); getWriter().position(TYPHeader.HEADER_LEN); int pos = getWriter().position(); header.getPointData().setPosition(pos); for (Writeable w : images) w.write(getWriter()); int len = getWriter().position() - pos; header.getPointData().setSize(len); if (len < 0x100) header.getPointIndex().setItemSize((char) 3); pos = getWriter().position(); for (PointInfo w : pointInfo) w.write(getWriter(), header.getPointData().getSize()); header.getPointIndex().setSize(getWriter().position() - pos); pos = getWriter().position(); for (Writeable w : drawOrder) w.write(getWriter()); header.getShapeStacking().setSize(getWriter().position() - pos); } public void writePost() { log.debug("syncing TYP file"); position(0); getHeader().writeHeader(getWriter()); } public static BitmapImage parseXpm(int type, int subtype, int day, String xpm) { try { BufferedReader br = new BufferedReader(new StringReader(xpm)); String[] header = br.readLine().split(" "); int w = Integer.parseInt(header[0]); int h = Integer.parseInt(header[1]); int c = Integer.parseInt(header[2]); int cpp = Integer.parseInt(header[3]); Map colors = new HashMap(); for (int i = 0; i < c; i++) { String l = br.readLine(); String[] ci = l.split("\t"); int r = Integer.parseInt(ci[1].substring(3, 5), 16); int g = Integer.parseInt(ci[1].substring(5, 7), 16); int b = Integer.parseInt(ci[1].substring(7, 9), 16); colors.put(ci[0], new Rgb(r, g, b, (byte) i)); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < h; i++) sb.append(br.readLine()); return new BitmapImage((byte) type, (byte) subtype, (byte) day, w, colors, cpp, sb.toString()); } catch (IOException e) { log.error("failed to parse bitmap", e); return null; } } public void createDrawOrder(byte typ, byte sub) { drawOrder.add(new DrawOrder((char) (typ | sub << 8), (char) 0, (byte) 0)); } public List getImages() { return images; } public List getPointInfo() { return pointInfo; } public List getDrawOrder() { return drawOrder; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/ShapeStacking.java0000644000076400007640000000126011114503661024010 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 15, 2007 */ package uk.me.parabola.imgfmt.app.typ; /** * @author Steve Ratcliffe */ public class ShapeStacking { // TODO give in content } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/PointInfo.java0000644000076400007640000000075711115044052023176 0ustar stevestevepackage uk.me.parabola.imgfmt.app.typ; import uk.me.parabola.imgfmt.app.ImgFileWriter; public class PointInfo { private final BitmapImage bitmap; public PointInfo(BitmapImage bitmap) { this.bitmap = bitmap; } public void write(ImgFileWriter writer, int maxOffset) { char wtype = (char) (bitmap.getSubtype() | bitmap.getTyp() << 5); writer.putChar(wtype); if (maxOffset < 0x100) writer.put((byte) bitmap.getOffset()); else writer.putChar((char) bitmap.getOffset()); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/typ/Rgb.java0000644000076400007640000000131011114503661021772 0ustar stevestevepackage uk.me.parabola.imgfmt.app.typ; import uk.me.parabola.imgfmt.FormatException; import uk.me.parabola.imgfmt.app.ImgFileWriter; public class Rgb { private int idx; public final int b; public final int g; public final int r; public Rgb(int r, int g, int b, int i) { this.b = b; this.g = g; this.r = r; idx = i; } public Rgb(Rgb rgb, byte idx) { b = rgb.b; g = rgb.g; r = rgb.r; this.idx = idx; } public void write(ImgFileWriter writer, byte type) { if (type != 0x10) throw new FormatException("Invalid color deep"); writer.put((byte) b); writer.put((byte) g); writer.put((byte) r); } int getIdx() { return idx; } void setIdx(int idx) { this.idx = idx; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/Label.java0000644000076400007640000000600011164230243021462 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 10-Jan-2007 */ package uk.me.parabola.imgfmt.app; import uk.me.parabola.imgfmt.app.labelenc.EncodedText; import uk.me.parabola.log.Logger; /** * Labels are used for names of roads, points of interest etc. * * There are different storage formats. * * 1. A 6 bit compact uppercase ascii format, that has escape codes for some * special characters. * * 2. An 8 bit format. This seems to be a fairly straightforward latin-1 like * encoding with no tricks to reduce the amount of space required. * * @author Steve Ratcliffe */ public class Label implements Comparable { private static final Logger log = Logger.getLogger(Label.class); // The compressed form of the label text. private final byte[] ctext; private final int length; // The offset in to the data section. private int offset; public Label(EncodedText etext) { ctext = etext.getCtext(); length = etext.getLength(); } public byte[] getCtext() { return ctext; } public int getLength() { return length; } /** * The offset of this label in the LBL file. The first byte of this file * is zero and an offset of zero means that the label has a zero length/is * empty. * * @return The offset within the LBL file of this string. */ public int getOffset() { if (ctext == null) return 0; else return offset; } public void setOffset(int offset) { this.offset = offset; } /** * Write this label to the given img file. * * @param writer The LBL file to write to. */ public void write(ImgFileWriter writer) { if (log.isDebugEnabled()) log.debug("put label", this.length); if (ctext != null) writer.put(ctext, 0, this.length); } /** * String version of the label, for diagnostic purposes. */ public String toString() { return "label at " + offset; } //public boolean equals(Object obj) { // Label other = (Label) obj; // return other.getOffset() == getOffset(); //} // //@Override //public int hashCode() { // return offset; //} public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; return offset == ((Label) o).offset; } public int hashCode() { return offset; } public int compareTo(Object other) { Label o = (Label)other; if(this == other) return 0; for(int i = 0; i < length && i < o.length; ++i) { int diff = (ctext[i] & 0xff) - (o.ctext[i] & 0xff); if(diff != 0) return diff; } if(length == o.length) return 0; return (length > o.length)? 1 : -1; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/Exit.java0000644000076400007640000000323411177352240021370 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Jan 1, 2008 */ package uk.me.parabola.imgfmt.app; import java.util.ArrayList; import java.util.List; import uk.me.parabola.imgfmt.app.lbl.ExitFacility; import uk.me.parabola.imgfmt.app.lbl.Highway; /** * Represent a motorway exit * * @author Mark Burton */ public class Exit { public final static String TAG_ROAD_REF = "exit:road_ref"; public final static String TAG_TO = "exit:to"; public final static String TAG_FACILITY = "exit:facility"; private final Highway highway; private Label label; private Label description; private List facilities = new ArrayList(); public Exit(Highway highway) { this.highway = highway; } public void setLabel(Label label) { this.label = label; } public void setDescription(Label description) { this.description = description; } public void addFacility(ExitFacility facility) { facilities.add(facility); } public boolean getOvernightParking() { return false; // FIXME } public Highway getHighway() { return highway; } public List getFacilities() { return facilities; } public Label getDescription() { return description; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/Area.java0000644000076400007640000000756311135200663021333 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 07-Dec-2006 */ package uk.me.parabola.imgfmt.app; import java.util.List; import uk.me.parabola.imgfmt.Utils; import uk.me.parabola.log.Logger; /** * A map area in map units. There is a constructor available for creating * in lat/long form. * * @author Steve Ratcliffe */ public class Area { private static final Logger log = Logger.getLogger(Area.class); private final int minLat; private final int minLong; private final int maxLat; private final int maxLong; /** * Create an area from the given coordinates. We ensure that no dimention * is zero. * * @param minLat The western latitude. * @param minLong The southern longitude. * @param maxLat The eastern lat. * @param maxLong The northern long. */ public Area(int minLat, int minLong, int maxLat, int maxLong) { this.minLat = minLat; if (maxLat == minLat) this.maxLat = minLat+1; else this.maxLat = maxLat; this.minLong = minLong; if (minLong == maxLong) this.maxLong = maxLong+1; else this.maxLong = maxLong; } public Area(double minLat, double minLong, double maxLat, double maxLong) { this(Utils.toMapUnit(minLat), Utils.toMapUnit(minLong) , Utils.toMapUnit(maxLat), Utils.toMapUnit(maxLong)); } public int getMinLat() { return minLat; } public int getMinLong() { return minLong; } public int getMaxLat() { return maxLat; } public int getMaxLong() { return maxLong; } public int getWidth() { return maxLong - minLong; } public int getHeight() { return maxLat - minLat; } public String toString() { return "(" + Utils.toDegrees(minLat) + ',' + Utils.toDegrees(minLong) + ") to (" + Utils.toDegrees(maxLat) + ',' + Utils.toDegrees(maxLong) + ')' ; } /** * Split this area up into a number of smaller areas. * * @param xsplit The number of pieces to split this area into in the x * direction. * @param ysplit The number of pieces to split this area into in the y * direction. * @return An area containing xsplit*ysplit areas. */ public Area[] split(int xsplit, int ysplit) { Area[] areas = new Area[xsplit * ysplit]; int xsize = getWidth() / xsplit; int ysize = getHeight() / ysplit; int xextra = getWidth() - xsize * xsplit; int yextra = getHeight() - ysize * ysplit; for (int x = 0; x < xsplit; x++) { int xstart = minLong + x * xsize; int xend = xstart + xsize; if (x == xsplit - 1) xend += xextra; for (int y = 0; y < ysplit; y++) { int ystart = minLat + y * ysize; int yend = ystart + ysize; if (y == ysplit - 1) yend += yextra; Area a = new Area(ystart, xstart, yend, xend); log.debug(x, y, a); areas[x * ysplit + y] = a; } } assert areas.length == xsplit * ysplit; return areas; } /** * Get the largest dimention. So either the width or heigh, depending * on which is larger. * * @return The largest dimention in map units. */ public int getMaxDimention() { return Math.max(getWidth(), getHeight()); } public boolean contains(Coord co) { return co.getLatitude() >= minLat && co.getLatitude() <= maxLat && co.getLongitude() >= minLong && co.getLongitude() <= maxLong; } public boolean isEmpty() { return minLat >= maxLat || minLong >= maxLong; } public boolean allInside(List coords) { for (Coord co : coords) { if (!contains(co)) return false; } return true; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/BufferedImgFileReader.java0000644000076400007640000001130611034116042024546 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt.app; import uk.me.parabola.imgfmt.ReadFailedException; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; import java.io.IOException; import java.nio.ByteBuffer; /** * Read from an img file via a buffer. * * @author Steve Ratcliffe */ public class BufferedImgFileReader implements ImgFileReader { private static final Logger log = Logger.getLogger(BufferedImgFileReader.class); // Buffer size, must be a power of 2 private static final int BUF_SIZE = 0x1000; private final ImgChannel chan; // The buffer that we read out of private final ByteBuffer buf = ByteBuffer.allocate(BUF_SIZE); private long bufStart; private int bufSize = -1; // We keep our own idea of the file position. private long position; public BufferedImgFileReader(ImgChannel chan) { this.chan = chan; } /** * Called when the stream is closed. Any resources can be freed. * * @throws IOException When there is an error in closing. */ public void close() throws IOException { chan.close(); } /** * Get the position. Needed because may not be reflected in the underlying * file if being buffered. * * @return The logical position within the file. */ public long position() { return position; } /** * Set the position of the file. * * @param pos The new position in the file. */ public void position(long pos) { position = pos; } /** * Read in a single byte from the current position. * * @return The byte that was read. */ public byte get() throws ReadFailedException { // Check if the current position is within the buffer fillBuffer(); int pos = (int) (position - bufStart); if (pos >= bufSize) return 0; // XXX do something else position++; return buf.get(pos); } /** * Read in two bytes. Done in the correct byte order. * * @return The 2 byte integer that was read. */ public char getChar() throws ReadFailedException { // Slow but sure implementation byte b1 = get(); byte b2 = get(); return (char) (((b2 & 0xff) << 8) + (b1 & 0xff)); } /** * Read a three byte signed quantity. * @return The read value. * @throws ReadFailedException */ public int get3() throws ReadFailedException { // Slow but sure implementation byte b1 = get(); byte b2 = get(); byte b3 = get(); return (b1 & 0xff) | ((b2 & 0xff) << 8) | (b3 << 16) ; } /** * Read in a 4 byte value. * * @return A 4 byte integer. */ public int getInt() throws ReadFailedException { // Slow but sure implementation byte b1 = get(); byte b2 = get(); byte b3 = get(); byte b4 = get(); return (b1 & 0xff) | ((b2 & 0xff) << 8) | ((b3 & 0xff) << 16) | ((b4 & 0xff) << 24) ; } /** * Read in an arbitary length sequence of bytes. * * @param len The number of bytes to read. */ public byte[] get(int len) throws ReadFailedException { byte[] bytes = new byte[len]; // Slow but sure implementation. for (int i = 0; i < len; i++) { bytes[i] = get(); } return bytes; } /** * Read a zero terminated string from the file. * @return A string * @throws ReadFailedException For failures. */ public String getZString() throws ReadFailedException { StringBuffer sb = new StringBuffer(); // Slow but sure implementation. for (byte b = get(); b != 0; b = get()) { sb.append((char) b); } return sb.toString(); } /** * Check to see if the buffer contains the byte at the current position. * If not then it is re-read so that it does. * * @throws ReadFailedException If the buffer needs filling and the file cannot be * read. */ private void fillBuffer() throws ReadFailedException { // If we are no longer inside the buffer, then re-read it. if (position < bufStart || position >= bufStart + bufSize) { // Get channel position on a block boundry. bufStart = position & ~(BUF_SIZE - 1); chan.position(bufStart); log.debug("reading in a buffer start=", bufStart); // Fill buffer buf.clear(); bufSize = 0; try { bufSize = chan.read(buf); } catch (IOException e) { throw new ReadFailedException("failed to fill buffer", e); } log.debug("there were", bufSize, "bytes read"); } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/SectionWriter.java0000644000076400007640000000344711135200663023261 0ustar stevesteve/* * Copyright (C) 2008 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 19-Jul-2008 */ package uk.me.parabola.imgfmt.app; import java.io.IOException; /** * A section writer wraps a regular writer so that all the offsets * are relative to the start of a section. * * @author Steve Ratcliffe */ public class SectionWriter implements ImgFileWriter { private final ImgFileWriter writer; private final Section section; private final int secStart; public SectionWriter(ImgFileWriter writer, Section section) { this.writer = writer; this.secStart = section.getPosition(); this.section = section; } public void sync() throws IOException { writer.sync(); } /** * Note that this does not close the underlying file. */ public void close() { if (section != null) section.setSize(writer.position() - secStart); //writer.close(); } public int position() { return writer.position() - secStart; } public void position(long pos) { writer.position(pos + secStart); } public void put(byte b) { writer.put(b); } public void putChar(char c) { writer.putChar(c); } public void put3(int val) { writer.put3(val); } public void putInt(int val) { writer.putInt(val); } public void put(byte[] val) { writer.put(val); } public void put(byte[] src, int start, int length) { writer.put(src, start, length); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/BufferedImgFileWriter.java0000644000076400007640000001045711154317465024645 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 07-Dec-2006 */ package uk.me.parabola.imgfmt.app; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import uk.me.parabola.imgfmt.ExitException; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.log.Logger; /** * A straight forward implementation that just keeps all the data in a buffer * until the file needs to be written to disk. * * @author Steve Ratcliffe */ public class BufferedImgFileWriter implements ImgFileWriter { private static final Logger log = Logger.getLogger(BufferedImgFileWriter.class); private static final int KBYTE = 1024; private static final int INIT_SIZE = 16 * KBYTE; private static final int GROW_SIZE = 128 * KBYTE; private static final int GUARD_SIZE = KBYTE; private final ImgChannel chan; private ByteBuffer buf = ByteBuffer.allocate(INIT_SIZE); private int bufferSize = INIT_SIZE; private int maxSize; public BufferedImgFileWriter(ImgChannel chan) { this.chan = chan; buf.order(ByteOrder.LITTLE_ENDIAN); } /** * Called to write out any saved buffers. The strategy may write * directly to the file in which case this would have nothing or * little to do. */ public void sync() throws IOException { buf.limit(maxSize); buf.position(0); log.debug("syncing to pos", chan.position(), ", size", buf.limit()); chan.write(buf); } /** * Get the position. Needed because may not be reflected in the underlying * file if being buffered. * * @return The logical position within the file. */ public int position() { return buf.position(); } /** * Set the position of the file. * * @param pos The new position in the file. */ public void position(long pos) { int cur = position(); if (cur > maxSize) maxSize = cur; buf.position((int) pos); } /** * Called when the stream is closed. Any resources can be freed. */ public void close() throws IOException { chan.close(); } /** * Write out a single byte. * * @param b The byte to write. */ public void put(byte b) { ensureSize(1); buf.put(b); } /** * Write out two bytes. Done in the correct byte order. * * @param c The value to write. */ public void putChar(char c) { ensureSize(2); buf.putChar(c); } /** * Write out a 3 byte value in the correct byte order etc. * * @param val The value to write. */ public void put3(int val) { ensureSize(3); buf.put((byte) (val & 0xff)); buf.putChar((char) (val >> 8)); } /** * Write out 4 byte value. * * @param val The value to write. */ public void putInt(int val) { ensureSize(4); buf.putInt(val); } /** * Write out an arbitary length sequence of bytes. * * @param val The values to write. */ public void put(byte[] val) { ensureSize(val.length); buf.put(val); } /** * Write out part of a byte array. * * @param src The array to take bytes from. * @param start The start position. * @param length The number of bytes to write. */ public void put(byte[] src, int start, int length) { ensureSize(length); buf.put(src, start, length); } /** * Make sure there is enough room for the data we are about to write. * * @param length The amount of data. */ private void ensureSize(int length) { if (buf.position() +length > bufferSize - GUARD_SIZE) { bufferSize += GROW_SIZE; if (bufferSize > 0xffffff) { // Previous message was confusing people, although it is difficult to come // up with something that is strictly true in all situations. throw new ExitException( "There is not enough room in a single garmin map for all the input data\n" + " The .osm file should be split into smaller pieces first."); } ByteBuffer newb = ByteBuffer.allocate(bufferSize); newb.order(ByteOrder.LITTLE_ENDIAN); buf.flip(); newb.put(buf); buf = newb; } } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/Writeable.java0000644000076400007640000000034511114503661022371 0ustar stevestevepackage uk.me.parabola.imgfmt.app; /** * Interface that can be implemented by objects that write to an ImgFile. * @author Thomas Lußnig */ public interface Writeable { public void write(ImgFileWriter writer); } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/0000755000076400007640000000000011216306457021116 5ustar stevestevemkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/TREHeader.java0000644000076400007640000002030411172432305023514 0ustar stevesteve/* * Copyright (C) 2007 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: Dec 14, 2007 */ package uk.me.parabola.imgfmt.app.trergn; import uk.me.parabola.imgfmt.ReadFailedException; import uk.me.parabola.imgfmt.app.Area; import uk.me.parabola.imgfmt.app.CommonHeader; import uk.me.parabola.imgfmt.app.ImgFileReader; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Section; import uk.me.parabola.log.Logger; import uk.me.parabola.util.EnhancedProperties; /** * @author Steve Ratcliffe */ public class TREHeader extends CommonHeader { private static final Logger log = Logger.getLogger(TREHeader.class); // The tre section comes in different versions with different length // headers. We just refer to them by the header length for lack of any // better description. public static final int TRE_120 = 120; public static final int TRE_184 = 184; private static final int TRE_188 = 188; // The header length to use when creating a file. private static final int DEFAULT_HEADER_LEN = TRE_188; // A map has a display priority that determines which map is on top // when two maps cover the same area. private static final int DEFAULT_DISPLAY_PRIORITY = 0x19; static final int MAP_LEVEL_REC_SIZE = 4; private static final char POLYLINE_REC_LEN = 2; private static final char POLYGON_REC_LEN = 2; private static final char POINT_REC_LEN = 3; private static final char COPYRIGHT_REC_SIZE = 0x3; static final int SUBDIV_REC_SIZE = 14; static final int SUBDIV_REC_SIZE2 = 16; private static final int POI_FLAG_TRANSPARENT = 0x2; // Bounding box. All units are in map units. private Area area = new Area(0,0,0,0); private int mapInfoSize; private int mapLevelPos; private int mapLevelsSize; private int subdivPos; private int subdivSize; private byte poiDisplayFlags; private int displayPriority = DEFAULT_DISPLAY_PRIORITY; private final Section copyright = new Section(COPYRIGHT_REC_SIZE); private final Section polyline = new Section(POLYLINE_REC_LEN); private final Section polygon = new Section(POLYGON_REC_LEN); private final Section points = new Section(POINT_REC_LEN); private final Section tre7 = new Section(points, (char) 13); private final Section tre8 = new Section(tre7, (char) 4); //private Section tre9 = new Section(tre8); private int mapId; public TREHeader() { super(DEFAULT_HEADER_LEN, "GARMIN TRE"); } /** * Read the rest of the header. Specific to the given file. It is guaranteed * that the file position will be set to the correct place before this is * called. * * @param reader The header is read from here. */ protected void readFileHeader(ImgFileReader reader) throws ReadFailedException { assert reader.position() == COMMON_HEADER_LEN; int maxLat = reader.get3(); int maxLon = reader.get3(); int minLat = reader.get3(); int minLon = reader.get3(); setBounds(new Area(minLat, minLon, maxLat, maxLon)); log.info("read area is", getBounds()); // more to do... mapLevelPos = reader.getInt(); mapLevelsSize = reader.getInt(); subdivPos = reader.getInt(); subdivSize = reader.getInt(); copyright.readSectionInfo(reader, true); reader.getInt(); poiDisplayFlags = reader.get(); displayPriority = reader.get3(); reader.getInt(); reader.getChar(); reader.get(); polyline.readSectionInfo(reader, true); reader.getInt(); polygon.readSectionInfo(reader, true); reader.getInt(); points.readSectionInfo(reader, true); reader.getInt(); int mapInfoOff = mapLevelPos; if (subdivPos < mapInfoOff) mapInfoOff = subdivPos; if (copyright.getPosition() < mapInfoOff) mapInfoOff = copyright.getPosition(); mapInfoSize = mapInfoOff - getHeaderLength(); reader.getInt(); reader.getInt(); reader.getInt(); copyright.readSectionInfo(reader, true); reader.getInt(); if (getHeaderLength() > 116) { reader.position(116); mapId = reader.getInt(); } } /** * Write the rest of the header. It is guaranteed that the writer will be set * to the correct position before calling. * * @param writer The header is written here. */ protected void writeFileHeader(ImgFileWriter writer) { writer.put3(area.getMaxLat()); writer.put3(area.getMaxLong()); writer.put3(area.getMinLat()); writer.put3(area.getMinLong()); writer.putInt(getMapLevelsPos()); writer.putInt(getMapLevelsSize()); writer.putInt(getSubdivPos()); writer.putInt(getSubdivSize()); copyright.writeSectionInfo(writer); writer.putInt(0); writer.put(getPoiDisplayFlags()); writer.put3(displayPriority); writer.putInt(0x110301); writer.putChar((char) 1); writer.put((byte) 0); polyline.writeSectionInfo(writer); writer.putInt(0); polygon.writeSectionInfo(writer); writer.putInt(0); points.writeSectionInfo(writer); writer.putInt(0); // There are a number of versions of the header with increasing lengths if (getHeaderLength() > 116) writer.putInt(getMapId()); if (getHeaderLength() > 120) { writer.putInt(0); tre7.writeSectionInfo(writer); writer.putInt(0); // not usually zero tre8.writeSectionInfo(writer); writer.putChar((char) 0); writer.putInt(0); } if (getHeaderLength() > 154) { MapValues mv = new MapValues(mapId, getHeaderLength()); mv.calculate(); writer.putInt(mv.value(0)); writer.putInt(mv.value(1)); writer.putInt(mv.value(2)); writer.putInt(mv.value(3)); writer.putInt(0); writer.putInt(0); writer.putInt(0); writer.putChar((char) 0); writer.putInt(0); } writer.position(getHeaderLength()); } public void config(EnhancedProperties props) { String key = "draw-priority"; if (props.containsKey(key)) setDisplayPriority(props.getProperty(key, 0x19)); if (props.containsKey("transparent")) poiDisplayFlags |= POI_FLAG_TRANSPARENT; } /** * Set the bounds based upon the latitude and longitude in degrees. * @param area The area bounded by the map. */ public void setBounds(Area area) { this.area = area; } public Area getBounds() { return area; } public void setMapId(int id) { mapId = id; } public void setPoiDisplayFlags(byte poiDisplayFlags) { this.poiDisplayFlags = poiDisplayFlags; } public int getMapInfoSize() { return mapInfoSize; } public void setMapInfoSize(int mapInfoSize) { this.mapInfoSize = mapInfoSize; } public int getMapLevelsPos() { return mapLevelPos; } public void setMapLevelPos(int mapLevelPos) { this.mapLevelPos = mapLevelPos; } public int getMapLevelsSize() { return mapLevelsSize; } public void setMapLevelsSize(int mapLevelsSize) { this.mapLevelsSize = mapLevelsSize; } public int getSubdivPos() { return subdivPos; } public void setSubdivPos(int subdivPos) { this.subdivPos = subdivPos; } public int getSubdivSize() { return subdivSize; } public void setSubdivSize(int subdivSize) { this.subdivSize = subdivSize; } public void setCopyrightPos(int copyrightPos) { //this.copyrightPos = copyrightPos; copyright.setPosition(copyrightPos); } public void incCopyrightSize() { copyright.inc(); } protected byte getPoiDisplayFlags() { return poiDisplayFlags; } public void setPolylinePos(int polylinePos) { polyline.setPosition(polylinePos); } public void incPolylineSize() { polyline.inc(); } public void setPolygonPos(int polygonPos) { polygon.setPosition(polygonPos); } public void incPolygonSize() { polygon.inc(); } public void setPointPos(int pointPos) { points.setPosition(pointPos); } public void incPointSize() { points.inc(); } protected int getMapId() { return mapId; } protected void setDisplayPriority(int displayPriority) { this.displayPriority = displayPriority; } public void setTre7Pos(int pos) { tre7.setPosition(pos); } public void incTre7() { tre7.inc(); } public int getDisplayPriority() { return displayPriority; } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/Polygon.java0000644000076400007640000000137710735217321023414 0ustar stevesteve/** * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Author: steve * Date: 22-Dec-2006 */ package uk.me.parabola.imgfmt.app.trergn; /** * A Polygon on a garmin map is pretty much treated like a line. * * @author Steve Ratcliffe */ public class Polygon extends Polyline { public Polygon(Subdivision div) { super(div); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/PolygonOverview.java0000644000076400007640000000150010735217321025127 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 01-Jan-2007 */ package uk.me.parabola.imgfmt.app.trergn; /** * Polygons just have a type (no subtype). * * @author Steve Ratcliffe */ public class PolygonOverview extends Overview { public PolygonOverview(int type, int minResolution) { super(SHAPE_KIND, type, minResolution); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/PointOverview.java0000644000076400007640000000147310735217321024602 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 01-Jan-2007 */ package uk.me.parabola.imgfmt.app.trergn; /** * Points have both a type and a subtype. * * @author Steve Ratcliffe */ public class PointOverview extends Overview { public PointOverview(int type, int minResolution) { super(POINT_KIND, type, minResolution); } } mkgmap-r1067/src/uk/me/parabola/imgfmt/app/trergn/Polyline.java0000644000076400007640000001160711202113173023543 0ustar stevesteve/* * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 11-Dec-2006 */ package uk.me.parabola.imgfmt.app.trergn; import java.util.ArrayList; import java.util.List; import uk.me.parabola.imgfmt.app.BitWriter; import uk.me.parabola.imgfmt.app.Coord; import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.app.Label; import uk.me.parabola.imgfmt.app.net.RoadDef; import uk.me.parabola.log.Logger; /** * Represents a multi-segment line. Eg for a road. As with all map objects * it can only exist as part of a subdivision. * * Writing these out is particularly tricky as deltas between points are packed * into the smallest number of bits possible. * * I am not trying to make the smallest map, so it will not be totally optimum. * * @author Steve Ratcliffe */ public class Polyline extends MapObject { private static final Logger log = Logger.getLogger(Polyline.class); // flags in the label offset private static final int FLAG_NETINFO = 0x800000; private static final int FLAG_EXTRABIT = 0x400000; // flags in the type private static final int FLAG_DIR = 0x40; private static final int FLAG_2BYTE_LEN = 0x80; private int number; // Reference to NET section, if any private RoadDef roaddef; // If a road gets subdivided into several segments, this // says whether this line is the last segment. Need this // for writing extra bits. private boolean lastSegment = true; // Set if it is a one-way street for example. private boolean direction; // The actual points that make up the line. private final List points = new ArrayList(); public Polyline(Subdivision div) { setSubdiv(div); } /** * Format and write the contents of the object to the given * file. * * @param file A reference to the file that should be written to. */ public void write(ImgFileWriter file) { // If there is nothing to do, then do nothing. if (points.size() < 2) { log.debug("less than two points, not writing"); return; } // Prepare for writing by doing all the required calculations. // Prepare the information that we need. LinePreparer w = new LinePreparer(this); BitWriter bw = w.makeBitStream(); // The type of feature, also contains a couple of flags hidden inside. byte b1 = (byte) getType(); if (direction) b1 |= FLAG_DIR; // Polylines only. int blen = bw.getLength() - 1; // allow for the sizes assert blen > 0 : "zero length bitstream"; assert blen < 0x10000 : "bitstream too long " + blen; if (blen >= 0x100) b1 |= FLAG_2BYTE_LEN; file.put(b1); // The label, contains a couple of flags within it. int loff = getLabel().getOffset(); if (w.isExtraBit()) loff |= FLAG_EXTRABIT; // If this is a road, then we need to save the offset of the label // so that we can change it to the index in the net section if (roaddef != null) { roaddef.addLabel(getLabel()); roaddef.addOffsetTarget(file.position(), FLAG_NETINFO | (loff & FLAG_EXTRABIT)); // also add ref label(s) if present List