spatialite labels

45 views
Skip to first unread message

andrea antonello

unread,
Mar 13, 2014, 12:05:10 PM3/13/14
to geopapara...@googlegroups.com
Hi all,
Mark and I made is a simple implementation of labels for spatialite layers.

Some comments:
- currently you can choose the tabel field to use, the text size and
toggle the visibility.
- all visible labels are drawn and without collision detection.
- labels are drawn after all the geometries of the table are drawn. So
they can't be covered by geometries of the same layer, but they can be
covered by other layers.
- for points, labels are drawn top-right considering the point size
- for polygons, labels are drawn in the centroid (no check is done if
it is inside the polygon)
- for lines, labels are drawn with a fancy android method called:
drawTextOnPath. It makes things simple, but it distorts often the
letters. Better then nothing anyways, and if paths are not too cusp,
it looks nice.

Apart of some mentioned problems, labels look quite nice.
If you want to test this, check out the nf_labels_splite branch, it is
done there.

Pull requests against it to fix or enhance stuff are more than welcome. :)

Cheers,
Andrea

Tim Howard

unread,
Mar 13, 2014, 12:08:22 PM3/13/14
to andrea antonello, geopapara...@googlegroups.com
Wow! Congratulations. That sounds like a very good implementation. We'll try to look at it soon. 
Tim



--
You received this message because you are subscribed to the Google Groups "geopaparazzi-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Johnson

unread,
Mar 14, 2014, 4:32:36 AM3/14/14
to geopapara...@googlegroups.com
This looks very good, even while testing a 'worst case scenario'.

I have compiled some images taken this morning and have made some notes on things that are not quite right.

andrea antonello

unread,
Mar 14, 2014, 4:39:16 AM3/14/14
to geopapara...@googlegroups.com
[...]
> This looks very good, even while testing a 'worst case scenario'.
>
> I have compiled some images taken this morning and have made some notes on
> things that are not quite right.
>
> https://github.com/geopaparazzi/geopaparazzi/wiki/Geometry-Labels-Test-Images-Version-01

Thanks for collecting the issues for some I might have solutions already.
I will read through them carefully asap.

Andrea


>
> Mark
>>
>>
>> Pull requests against it to fix or enhance stuff are more than welcome. :)
>>
>> Cheers,
>> Andrea
>

Radagast

unread,
Mar 14, 2014, 11:27:49 AM3/14/14
to geopapara...@googlegroups.com
Looks very good.  I will start testing asap.

Radagast

unread,
Mar 15, 2014, 8:58:35 AM3/15/14
to geopapara...@googlegroups.com
Hey Andrea,

I dont see the "nf_labels_splite" branch? Do you mean "spatialite_views" branch?

Nick


On Thursday, March 13, 2014 12:05:10 PM UTC-4, andrea antonello wrote:

Mark Johnson

unread,
Mar 15, 2014, 9:14:57 AM3/15/14
to geopapara...@googlegroups.com


On Saturday, 15 March 2014 13:58:35 UTC+1, Radagast wrote:
Hey Andrea,

I dont see the "nf_labels_splite" branch? Do you mean "spatialite_views" branch?
That was incorporated into master this morning.

"spatialite_views" is the same but some work for proper view support, but with the new spatialite 4.1.1 to replace the 3.0.1 version.
- still experimental - but no errorsuntil now.

Mark

Radagast

unread,
Mar 15, 2014, 8:03:23 PM3/15/14
to geopapara...@googlegroups.com
Oh OK.  So I can use master now right?

Mark Johnson

unread,
Mar 16, 2014, 1:10:10 AM3/16/14
to geopapara...@googlegroups.com


On Sunday, 16 March 2014 01:03:23 UTC+1, Radagast wrote:
Oh OK.  So I can use master now right?
Yes.

Radagast

unread,
Mar 17, 2014, 2:03:38 PM3/17/14
to geopapara...@googlegroups.com
Is this implemented in the google market release ?

Radagast

unread,
Mar 18, 2014, 11:13:31 AM3/18/14
to geopapara...@googlegroups.com
Hey Andrea,

What would you recommend for creating the labels layer?  Would QGIS work?  


On Friday, March 14, 2014 4:39:16 AM UTC-4, andrea antonello wrote:
[...]
> This looks very good, even while testing a 'worst case scenario'.
>
> I have compiled some images taken this morning and have made some notes on
> things that are not quite right.
>
> https://github.com/geopaparazzi/geopaparazzi/wiki/Geometry-Labels-Test-Images-Version-01

Thanks for collecting the issues for some I might have solutions already.
I will read through them carefully asap.

Andrea


>
> Mark
>>
>>
>> Pull requests against it to fix or enhance stuff are more than welcome. :)
>>
>> Cheers,
>> Andrea
>
> --
> You received this message because you are subscribed to the Google Groups
> "geopaparazzi-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Mark Johnson

unread,
Mar 18, 2014, 11:11:05 PM3/18/14
to geopapara...@googlegroups.com


On Monday, 17 March 2014 19:03:38 UTC+1, Radagast wrote:
Is this implemented in the google market release ?
No

Mark Johnson

unread,
Mar 19, 2014, 12:12:03 AM3/19/14
to geopapara...@googlegroups.com


On Tuesday, 18 March 2014 16:13:31 UTC+1, Radagast wrote:
Hey Andrea,

What would you recommend for creating the labels layer?  Would QGIS work?
(I am assuming that you are asking about Geometry-Labels)
I would not speak about 'labels layer' at all - that is misleading.
- to be precise: this is about a 'Geometry-Overlay', with EXPERIMENTAL Label support for the Geometry being shown
-- the chosen Label is a field/column of the record that contains the Geometry

Any program can be used that supports basic sqlite record support.
- care should, however, be taken when using non-spatialite aware programs: that they do NOT interfere with the BLOB field that contains the Geometry

QGIS: there is a basic field support in QGIS (Attributes), but I have found this to be sometimes faulty.
- my impression is that they don NOT query the attributes of the table to determine the data type of the field correctly
-- geopaparazzi does this when reading the fields that can be used as Lables
-- they seem to interpret the data in the first record and then make, often wrongly, assumptions
Sample:

CREATE TABLE berlin_ortsteil_segments (
 id_segment INTEGER PRIMARY KEY,
 name TEXT,
 admin_level TEXT  DEFAULT '10',
 belongs_to_01 TEXT DEFAULT '',
 belongs_to_02 TEXT DEFAULT '',
 valid_since DATE DEFAULT '0001-01-01',
 valid_until DATE DEFAULT '3000-01-01'
 -- LINESTRING : to build POLOYGONS
, "soldner_segment" LINESTRING)

1    Alt-Cölln,Alt-Berlin    10,9,4    1902010101    1902010102                        1237-10-12    1920-09-30
..
80    Mitte,Moabit 1920    10,9     1911000101     1902010119,1911000102    1920-10-01    1938-03-31

When shown in QGIS the field 'belongs_to_02' of row 80 is shown as 1902010119 and not 1902010119,1911000102
- it looks as if it assumes (falsely) that the field 'belongs_to_02' is an INTEGER and therefore cuts off everything that cannot belong to an INTEGER
- this does not ALWAYS happen for some reason, but as show in the second image, in the Form it is being cut off
-- when saved - it is still there and look at what it did to the date
-- this is, of course, a disaster and can ruin a Database.
Also the primary key 'id_segment' is not being shown in the list, which make it difficult to identify
- I often have to set the Start/EndPoint of one line to another Line and for this the primary key is needed

Good as the geometry editing is, the rest of this logic is badly designed - and what is worse: avoidable

So great care must be taken when working with QGIS.

Mark Johnson

20140319.qgis_attributes_01.png
20140319.qgis_attributes_02.png

Radagast

unread,
Mar 19, 2014, 3:26:39 PM3/19/14
to geopapara...@googlegroups.com
Hello Mark,

Based on what you have mentioned I do not think I will use QGIS.  It seems to be too faulty.  What field in the table is used for labels?  Could you maybe provide a sample .sqlite layer file that contains geometry-labels?  BTW do you recommend any tools or utilities for this?

Thanks.

Regards,

Radagast

Mark Johnson

unread,
Mar 20, 2014, 1:12:48 AM3/20/14
to geopapara...@googlegroups.com
2014-03-19 20:26 GMT+01:00 Radagast <promptn...@gmail.com>:

Hello Mark,

Based on what you have mentioned I do not think I will use QGIS.  It seems to be too faulty.
This is a misunderstanding.
- there are portions of QGIS that do not work well
-- many of the main-Icons are blank (I must wait for the Tool-Tips to show up to know which button is which)
-- and the problems with the field attributes, which was meant as a warning ONLY, must also be taken into consideration

But otherwise I use QGIS heavily for the development of my geometries.
With high scale geo-referenced Images of present maps and geo-referenced historical maps I am creating a set of the political boundaries from about 1700 until today.

With the present developer version (2.2) of QGIS this works very well with the present Spatialite (4.1.1) and is very reliable.
However I must do a lot of line Splitting, Merging etc. for which I use the spatialite_gui.
- so care must be taken to turn of the editing modus in QGIS  before executing this commands
- after the command, the changed geometry will be update automaticly when you move the screen slightly
-- in this way you can see if you 'goofed' up the command or that if the result is correct

Without the visual functionality that QGIS offers, this task would not be possible.
 
 What field in the table is used for labels?  Could you maybe provide a sample .sqlite layer file that contains geometry-labels?  
If you what to play around with this then download the following 2 file:
- with the browser enter: http://www.mj10777.de/public/download/mbtiles/
-- 2005.Berlin_Umgebung_10000.mbtiles [118 MB]
- with the browser enter: http://www.mj10777.de/public/download/geopaparazzi/berlin_points_linestrings_polygons/
-- berlin_points_linestrings_polygons.db [4.3 MB]

This first is a small map of Berlin (1:10000), just drag it into the QGIS-Layer window
- this is a mbtiles map that will also work with geopaparazzi, as indeed all from geopaparazzi created mbtiles files can be used in QGIS

The second is a small sample of points, linestrings and polygons that I created for Andrea to use to test the Lables in geopaparazzi

After draging the mbtiles file to the QGIS-Layer, do the same for the berlin_points_linestrings_polygons.db
- you should see something shown in '20140320.qgis_useage_01.png'
-- select the 'berlin_ortsteil_segments 'LineString'

Then, right click the Layer-entry 'berlin_ortsteil_segments': select properties
- in that dialog: select 'Style' (I am guessing the English names)
-- you should see something as shown in '20140320.qgis_useage_02.png'
--- the default thin line is hard to see - I use the 'Construction', which should be there by default
---- click 'Apply' and you should see the lines clearly in the background

- in that dialog: select 'Labelling' (in German it is 'Beschriftung')
-- you should see something as shown in '20140320.qgis_useage_03.png'
- there is a checkBox on the Top/Left 'Label Layer with'
-- use the ComboBox to select which (non-Geometry) Field of the table to use as a Label
--- select 'name'
---> this is the SAME process as needs to be done in geopaparazzi
----> all that QGIS or geopaparazzi do,
------ is to remember which one of the existing fields of the table is to be used as a label and whether it is to be shown or not

Click OK and zoom into the middle of the map and you should something similar to
- '20140320.qgis_useage_04.png'
 
BTW do you recommend any tools or utilities for this?
See above: QGIS
- there is a QGIS plugin called 'Qspatialite' which can be used to create a new Database
--> '20140320.qgis_useage_05.png'

I don't use this plugin often, since I create my database with sql-scripts.
But is is useful when you want to create any sort of geometry 'on the fly'.

Hope this helps

Mark Johnson
To unsubscribe from this group and stop receiving emails from it, send an email to geopaparazzi-de...@googlegroups.com.
20140320.qgis_useage_05.png
20140320.qgis_useage_04.png
20140320.qgis_useage_03.png
20140320.qgis_useage_02.png
20140320.qgis_useage_01.png

Radagast

unread,
Mar 22, 2014, 5:58:06 PM3/22/14
to geopapara...@googlegroups.com, mj1...@googlemail.com
Thanks Mark.  This was extremely helpful.  So in geopaparazzi we can choose what field to use.   What does field type have to be?  Text?
Again thank you for all the help I really appreciate it.  

Regards,

Radagast

Thanks.

Regards,

Radagast
> For more options, visit https://groups.google.com/d/optout.

Mark Johnson

unread,
Mar 22, 2014, 10:58:56 PM3/22/14
to geopapara...@googlegroups.com, mj1...@googlemail.com


On Saturday, 22 March 2014 22:58:06 UTC+1, Radagast wrote:
Thanks Mark.  This was extremely helpful.  So in geopaparazzi we can choose what field to use.   What does field type have to be?  Text?
Again thank you for all the help I really appreciate it.
Any non-geometry (Blob) field can be chosen.

Radagast

unread,
Mar 24, 2014, 10:39:13 AM3/24/14
to geopapara...@googlegroups.com, mj1...@googlemail.com
OK.

Radagast

unread,
Mar 24, 2014, 10:44:26 AM3/24/14
to geopapara...@googlegroups.com
Yah but isn't the NAME field "TEXT".
Reply all
Reply to author
Forward
0 new messages