Inkscape.org
Creating New Extensions KML / KMZ Import Extension
  1. #1
    Franklin Franklin @franklin204
    *

    Hello,

    I'm working on an extension to import KML files (Geodata XML files by google) into Inkscape using various projections (to replace my former conversion website..)

    I've few questions

    • Do you think it could be included into inkscape (or it's too small public ?) (including 80% of test coverage is some work.. ;) )
    • As the gui could not be responsive (to hide/disable field according to choice), Is there some gnome GUI extension exemple ?
    • is it possible to change the background color of the new document (basically to set checkerboard background)

    Thank you

    Import4
    Result3
    Result2
    Result1
    Import3
    Import2
    Import1
  2. #2
    Franklin Franklin @franklin204

    Point 3 solved with:

    doc.getroot().namedview.set("inkscape:pagecheckerboard", "true")
  3. #3
    Martin Owens Martin Owens @doctormo🌹🧀

    Hi anonymous developer 😉

    1. It's possible to include this in Inkscape, if you wanted. If it's Free Software licensed and has good tests etc. But it's also possible to add it to the new extension manager which is currently in beta for the 1.1 release, but should allow extensions authors to let users install their works.

    2. A GUI can be done, the extensions manager is an example codebase https://gitlab.com/inkscape/extras/extension-manager, as is the clipart importer https://gitlab.com/doctormo/inkscape-import-clipart/-/blob/master/import_clipart.py.

    Let me know here what you might do, I'm interested in getting extensions authors into the manager system.

  4. #4
    Franklin Franklin @franklin204
    *

    - double post -

  5. #5
    Franklin Franklin @franklin204
    *

    Hello,

    Thank you for the informations.

    I didn't heard about the extension manager yet. It could be a good option to first add it as an external extension, and then see if it could/should be bunddled with inkscape. I guess the idea behind the extension manager is to not include to many think in the core program 😉.

    That way I can put a more restrictive licence (something like AGPL) but change it latter to the Inkscape GPL one...

    I'll have a look at the extension-manager code to see the custom GUI 😄 !

    Thank you  again,

    Franklin

  6. #6
    Franklin Franklin @franklin204

    Hi,

    Here is a first version: https://gitlab.com/franklin204/inkscape-kml2svg-extension

    I didn't implement a custom GUI yet but the import KML/KMZ extension is functional.

    Export back is only supported for KML (not KMZ yet) and only if projection is Mercator (I need to code the reverse projection for all others...).

    Thanks for your feedback.

    Franklin

  7. #7
    Franklin Franklin @franklin204

    Hello !

    Version 0.0.4 is out, it fix default text style value and inx syntax errors.

    Franklin

  8. #8
    inklinea inklinea @inklinea⛰️
    *

    This is a really cool extension.

    In the UK, each postcode area has a page on wikipedia.

    You can download a KML file from each page.

    For example: https://en.wikipedia.org/wiki/BB_postcode_area

    Is it possible to add 

    <Placemark><name>BB18</name><description>BB18 postcode district</description>

    For each area ? 

    ( I randomised the colours ) 

    Screenshot From 2023 04 28 20 55 33
  9. #9
    Franklin Franklin @franklin204
    *

    Hello,

    Thank you for your feedback. I'm not 100% sure of the request:

    - the SVG already contains theses information into SVG elements attributes (visible in object properties/XML explorer)

    - do you mean adding these information as additional text on the final SVG ?

     

    Tmp123456
  10. #10
    inklinea inklinea @inklinea⛰️

    "- do you mean adding these information as additional text on the final SVG ?"

    Yes :)

    I can see the choice for font 'Arial', but I cannot get the labels to appear.

  11. #11
    Franklin Franklin @franklin204
    *

    The font choice was for the conversion of KML "Point" placemarks to text in the SVG.

    The name and descriptions are 'only' attributes of the shape, not standalone elements.

    However, i just push an update to an extra options in expert mode to include them:

    • Convert name attribute to text
    • Convert description attribute to text

    The label and descriptions are placed at the center of the corresponding object (which may overlay other texts & objects..).

    The main issue is that saving back to KML will add theses labels as additional Placemark point...

    Available for testing in master (no tag yet): https://gitlab.com/franklin204/inkscape-kml2svg-extension/-/archive/master/inkscape-kml2svg-extension-master.zip

     

    G3078
    G2825
    New Options
  12. #12
    Franklin Franklin @franklin204
    *

    Also added an extra option to randomize color at import (if color information is missing into KML/KMZ), just for fun 😊

    G1048
    G314
    G1336
  13. #13
    inklinea inklinea @inklinea⛰️
    *

    Yes that's really good.

    I just chose the name only and the random fill :)

    Can the Text be put into it's own layer ? 

     

    Screenshot From 2023 04 29 17 13 13
  14. #14
    Franklin Franklin @franklin204

    Everything is possible, but that's not really a very common use-case, so it's probably not interesting to add it to the extension I think... (In fact I should probably put labels&description into a group with the form/shape/line !)

    You can move all texts to the top or to an other layer by selecting a single text, right click > Select Same > Object Type

     

  15. #15
    Franklin Franklin @franklin204

    Hello !

    Version 0.0.5 is out, it fix default text style value and inx syntax errors.

    This version:

    • Add options to auto-colorize polygons and add Placemark name and/or description to SVG
    • Fix issues (wrong global document size, conversion crash on math.log(0))
    • Fix manifest ('&' unescaped symbols in inx files)

    Franklin

  16. #16
    Franklin Franklin @franklin204

    Hello !

    Version 0.0.6 is out, it fix default text style value and inx syntax errors.

    This version:

    • create a solid root layer with import filename
    • remove empty path when extracting a geometry or multigeometry
    • fix crash when gemetry contains only a Point

    Franklin