{"action":"closed","issue":{"url":"https://api.github.com/repos/mapserver/mapserver/issues/4242","repository_url":"https://api.github.com/repos/mapserver/mapserver","labels_url":"https://api.github.com/repos/mapserver/mapserver/issues/4242/labels{/name}","comments_url":"https://api.github.com/repos/mapserver/mapserver/issues/4242/comments","events_url":"https://api.github.com/repos/mapserver/mapserver/issues/4242/events","html_url":"https://github.com/mapserver/mapserver/issues/4242","id":3963369,"number":4242,"title":"User defined order for LABEL POSITION AUTO","user":{"login":"mapserver-bot","id":1608057,"avatar_url":"https://avatars.githubusercontent.com/u/1608057?v=3","gravatar_id":"","url":"https://api.github.com/users/mapserver-bot","html_url":"https://github.com/mapserver-bot","followers_url":"https://api.github.com/users/mapserver-bot/followers","following_url":"https://api.github.com/users/mapserver-bot/following{/other_user}","gists_url":"https://api.github.com/users/mapserver-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/mapserver-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapserver-bot/subscriptions","organizations_url":"https://api.github.com/users/mapserver-bot/orgs","repos_url":"https://api.github.com/users/mapserver-bot/repos","events_url":"https://api.github.com/users/mapserver-bot/events{/privacy}","received_events_url":"https://api.github.com/users/mapserver-bot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapserver/mapserver/labels/Enhancement","name":"Enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/mapserver/mapserver/labels/MapServer%20C%20Library","name":"MapServer C Library","color":"ffffff"},{"url":"https://api.github.com/repos/mapserver/mapserver/labels/No%20Recent%20Activity","name":"No Recent Activity","color":"ededed"},{"url":"https://api.github.com/repos/mapserver/mapserver/labels/version-master","name":"version-master","color":"ffffff"}],"state":"closed","locked":false,"assignee":{"login":"sdlime","id":1599227,"avatar_url":"https://avatars.githubusercontent.com/u/1599227?v=3","gravatar_id":"","url":"https://api.github.com/users/sdlime","html_url":"https://github.com/sdlime","followers_url":"https://api.github.com/users/sdlime/followers","following_url":"https://api.github.com/users/sdlime/following{/other_user}","gists_url":"https://api.github.com/users/sdlime/gists{/gist_id}","starred_url":"https://api.github.com/users/sdlime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdlime/subscriptions","organizations_url":"https://api.github.com/users/sdlime/orgs","repos_url":"https://api.github.com/users/sdlime/repos","events_url":"https://api.github.com/users/sdlime/events{/privacy}","received_events_url":"https://api.github.com/users/sdlime/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2012-04-04T00:33:19Z","updated_at":"2016-02-23T16:13:01Z","closed_at":"2016-02-23T16:13:01Z","body":"**Reporter: woodbri**\n**Date: 2012/03/13 - 18:57**\n**Trac URL:** http://trac.osgeo.org/mapserver/ticket/4242\nI mentioned in another thread the it would be nice to be able to control the order of the label attempts, maybe by listing them in order of preference. I found it very hard to get a layout of labels that I felt looked good. Using POSITION CC ended up being the best for the example of placing state abbreviations on the states. Using AUTO biases the labels to the left as we start labeling positions with UL\r\n\r\nIn most of the Automatic Label Positioning papers I have read they seem to express that the cartographically preferred order to be: CR, CL, UC, LC, UR, LR, UL, LL or in matrix form:\r\n\r\n\n```\r\n 7 3 5\r\n 2 X 1\r\n 8 4 6\r\n```\n\r\nWhere X is the label point. That said, I think the order should be\r\n\r\n\n```\r\n 6 1 5\r\n 4 X 3\r\n 8 2 7\r\n```\n\r\n\r\nor UC, LC, CR, CL, UR, UL, LR, LL. And often I would use CC in the first position.\r\n\r\nI bring this up because we probably need also to change the label positioning order dynamically (algorithmically) when there is a leader line and my assumption is that have some facility to do this would benefit both. The ideal order for positioning the label at the end of the leader would be to pick positions that are farthest from the object end of the leader. I think this will make for better looking labels and layout.\r\n\r\n\n```\r\n  5 3 1\r\n  7 X 2\r\n  8/6 4\r\n  /           6 4 2\r\n o------------8-X 1\r\n  \\           7 5 3\r\n  8\\6 4\r\n  7 X 2\r\n  5 3 1\r\n```\n\r\n\r\nAbove are few examples where o is the object end of the leader, X is the label end of the leader and the number are the positions to try in order.\r\n\r\nThe above forces the label to minimize intersection with its own leader and in general pushes the label away from an already crowded area.\r\n\r\n'''tbonfort responded with:'''\r\n\r\nFor the time being this kind of adjustment isn't possible. The whole\r\nshapeObj representing the label+markers is computed during the normal (i.e. not offsetted) phase of the labelcache rendering. If the label collides during this labelcache phase, then the offsetted position is determined by translating the computed shapeObj until it fits somewhere else. As such, it isn't possible to modify the label position once the offsetting phase has started, without having to recompute the shapeObj of the label+marker at each offsetted position.\r\n\r\nI do agree that the final result would be better this way for certain use-cases (the use-case aimed-for for this initial implementation actually requires the label to remain fixed compared to its marker), and would apply when using label-level leader lines (instead of class-level ones, implemented now)\r\n"}}