osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.73k stars 1.03k forks source link

OMC gpx -> obf #18866

Closed mariush444 closed 3 months ago

mariush444 commented 11 months ago

is it possible to add support for style of tracks and points?

./utilities.sh convert-gpx-to-obf xxxxx creates tracks as a very thin red line and track points as red circle with small white star.

It would be nice to have possibility to create tracks with defined width and color as an option. Track point should be the same as define in gpx (icon and color)

vshcherb commented 11 months ago

To do: We need to convert color from GPX and icons (from GPX OsmAnd format), so it look identical as GPX and as OBF

brad10281 commented 11 months ago

If you add extensions to each track in the GPX file, it will keep the color when converting to OBF. However, I was not able to get the width to change.

Example: `

#00842b 10
<name>Track</name>
<trkseg>
  <trkpt lat="44.486968014389277" lon="-85.290206596255302" />
  <trkpt lat="44.486643970012665" lon="-85.290624769404531" />
</trkseg>

`

mariush444 commented 11 months ago

Finally I got the same result. Reddit ;)

DmitryAlexei commented 9 months ago

2 tasks:

brad10281 commented 5 months ago

Any update here? I would love the ability to change the width of the track in the resulting obf file. Are there any other ways to accomplish this?

sonora commented 5 months ago

Issue #19892 deals with rhe 'Waypoint' appearance (color/icon) portion of this question and seems currently 'work in progress'.

I am not aware of any activity about the track width, though. It would be coding similarly to what has recently been achieved here: https://github.com/osmandapp/OsmAnd/issues/20051

RZR-UA commented 4 months ago

Bugs and notes:

RZR-UA commented 4 months ago

Tech plan:

Note: width might be string: thin/medium/bold or int-value (custom)

xmd5a:

RZR-UA commented 3 months ago

thin

medium

bold

custom-specified (not thin/medium/bold width=X) should be supported later

vshcherb commented 3 months ago

Question about track - route (https://github.com/osmandapp/OsmAnd-Issues/issues/2277)

Connected task: https://github.com/osmandapp/OsmAnd/issues/18876

mariush444 commented 3 months ago

The link https://github.com/osmandapp/OsmAnd-Issues/issues/2277 doesn't work. I'm not sure if the chackboxe's are for user's voting or for osmand team. If it is user voting then I vote 2 then 1.

RZR-UA commented 3 months ago

@mariush444, Issue 2277 is our internal task to implement travel OBF collection (just a reminder for connected tasks). The checkboxes are used as a TODO list for the current Issue, and I'm going to prettify waypoint icons and try to implement GPX-like customizations. I agree with you about 2 and 1 indeed.

RZR-UA commented 3 months ago

Some waypoint customization has been implemented. It's far away from the ideal look (as GPX points), but it renders much faster.

GPX-points OBF-points
1 2
RZR-UA commented 3 months ago

Devel notes:

Kotlin:

Platforms:

GPX:

UI:

Bugs:

original / fixed:

RZR-UA commented 3 months ago

TODO:

RZR-UA commented 3 months ago

How to test (for OsmAnd QA team):

  1. Use master/nightly build of OsmAnd Android
  2. Choose 2-3 GPX to test (GPX should include track and points and be located in one region)
  3. Randomize the appearance of the tracks (use different colors, widths, show_arrows, etc.)
  4. Organize points into 2-3 point groups, randomize point colors, icons, etc.
  5. Save each Track using the "Share track" feature (save them to GPX-files)
  6. Create a track folder ("Test folder") and import previously saved files into the folder.
  7. Sync your account to OsmAnd Cloud
  8. Log in to OsmAnd Web using your account
  9. Find your "Test folder" and click on "Download as OBF collection" in the menu
  10. The file "OsmAndCollection.travel.obf" will be downloaded as a result
  11. Install another (clean) master/nightly OsmAnd Android build, download the required maps
  12. Import the OBF file into freshly installed OsmAnd (Maps -> Local -> Standard -> Import)
  13. TEST: your tracks should appear on the map with the same color and width as set in clause 3
  14. TEST: your points should have the same color and icon as set in clause 4
  15. Select "Travel guides" from the main menu and click on some of your tracks there. The track should be saved and displayed on the map immediately
  16. TEST: open the saved track. Compare color, width, appearance, points groups, points colors, and points icons. All should be the same as you have saved before in clauses 3, 4
  17. Retry 15-16 with all other tracks from the test folder.

Happy testing!

vshcherb commented 3 months ago
RZR-UA commented 3 months ago

OsmAnd iOS report:

  1. The style is OK (track width/color OK, custom icons/colors OK) - screenshot_1
  2. Points are clickable (with details), but the track is not clickable - screenshot_2
  3. The Travel Guides (main menu) shows the track without any actions ("Save" is not implemented?) - screenshot_3
  4. No section like Android "Travel routes" is implemented (in the Map menu)

1

2

3

DmitryAlexei commented 1 month ago

Tested using OsmAnd~ 4.9.0#3365m, released: 2024-10-07 and TestFlight 4.8.3.6 on iPhone 13 mini and on the desktop version

Image

Bugs?

brad10281 commented 1 month ago

I confirmed this is working as expected. Is there any way to get transparency applied to the color?

RZR-UA commented 1 month ago

@brad10281 you could tune GPX-in-OBF colors by editing routes.addon.render.xml file in OsmAnd files/rendering folder.

For example, you can try the following block with transparent colors:

(find the block by OBF-GPX relation track width/color)

Transparent colors:

<apply_if additional="color_white" color="#44ffffff"/>
<apply_if additional="color_gray" color="#44999999"/>
<apply_if additional="color_darkyellow" color="#44afb61c"/>
<apply_if additional="color_lightgreen" color="#446cb52b"/>
<apply_if additional="color_lightblue" color="#442ec6ff"/>
<apply_if additional="color_red" color="$osmcRedColor"/>
<apply_if additional="color_orange" color="$osmcOrangeColor"/>
<apply_if additional="color_brown" color="$osmcBrownColor"/>
<apply_if additional="color_yellow" color="$osmcYellowColor"/>
<apply_if additional="color_green" color="$osmcGreenColor"/>
<apply_if additional="color_blue" color="$osmcBlueColor"/>
<apply_if additional="color_purple" color="$osmcPurpleColor"/>
<apply_if additional="color_black" color="$osmcBlackColor"/>

And place it instead of the standard colors:

(find the block by OBF-GPX track colors)

Standard colors:

<apply_if additional="color_white" color="#ffffff"/>
<apply_if additional="color_red" color="#ff0000"/>
<apply_if additional="color_orange" color="#ff7200"/>
<apply_if additional="color_brown" color="#ba7007"/>
<apply_if additional="color_darkyellow" color="#afb61c"/>
<apply_if additional="color_yellow" color="#edc300"/>
<apply_if additional="color_lightgreen" color="#6cb52b"/>
<apply_if additional="color_green" color="#00842b"/>
<apply_if additional="color_lightblue" color="#2ec6ff"/>
<apply_if additional="color_blue" color="#4e4eff"/>
<apply_if additional="color_purple" color="#a71de1"/>
<apply_if additional="color_gray" color="#999999"/>
<apply_if additional="color_black" color="#000000"/>

photo_2024-10-31_08-53-57

brad10281 commented 1 month ago

Thanks for the response. I'll give this a try.

One more question, What are all of the "0's" that are now displayed on the imported map? Is there a way to get rid of them? Screenshot_20241031_093715_OsmAnd

RZR-UA commented 1 month ago

The "0" will soon serve as the click-on-map icon. This feature is under construction now. Could you share your OBF file and the GPX tracks included in it (create ZIP archive)?

To remove it manually, you can play with the section OBF-GPX usual shields (based on textLength) in routes.addon.render.xml file.

Just try to edit out the following lines:

<case nameTag="ref" textOnPath="false" textColor="#404040" textShield="yellow_square_9_road_shield">
  <apply_if textLength="1" textShield="yellow_hexagon_3_road_shield"/>
  <apply_if textLength="2" textShield="yellow_hexagon_4_road_shield"/>
  <apply_if textLength="3" textShield="yellow_hexagon_5_road_shield"/>
  <apply_if textLength="4" textShield="yellow_square_6_road_shield"/>
  <apply_if textLength="5" textShield="yellow_square_7_road_shield"/>
  <apply_if textLength="6" textShield="yellow_square_8_road_shield"/>
</case>
brad10281 commented 1 month ago

Just wondering, what exactly is the "click-on-map icon"?

That screenshot must have been a one-of-a-kind. I cannot get that many 0's to display on the screen anymore. It only shows one or two now. I attached the GPX file here. It's a rather large file. MI ORV Route.gpx.txt

RZR-UA commented 1 month ago

The "click-on-map" (aka Road Shield) icon will activate the Save-to-GPX dialog in the future. Additionally, GPX files would have unique tags such as shield_fg, shield_bg, shield_text, and shield_textcolor to customize the Shield appearance.

You can check how it could be displayed on our development screenshot:

shields

brad10281 commented 1 month ago

Do you have an example of how to implement that in the GPX file? Does this work in v4.9.2? Is the idea to show a shield for each track segment?

RZR-UA commented 1 month ago

The feature is currently under construction.

The current approach is to define 1 shield_fg/bg/text per 1 GPX file, not for each distinct segment.

Your case with a really big GPX file seems unique. Your GPX has 34k points, which is greater than a standard Garmin device can display (AFAIK, a maximum of 20k per 1 GPX).

PS. OBF generation based on this kind of GPX-tags will be available soon. You could try matching the tags in the example below with the corresponding sections of routes.addon.render.xml (XML-file has already been added in 4.9.2):

  <metadata>
    <name>Terchovsko - Oravská cyklomagistrála</name>
    <desc>Strečno - Terchová - Novoť</desc>
    <extensions>
      <osmand:relation_gpx>yes</osmand:relation_gpx>
      <osmand:color>red</osmand:color>
      <osmand:shield_text>C</osmand:shield_text>
      <osmand:shield_textcolor>red</osmand:shield_textcolor>
      <osmand:shield_bg>osmc_white_bg</osmand:shield_bg>
    </extensions>
  </metadata>