Using properties MinVisible and MaxVisible

Topics: Algorithms
Editor
May 11, 2012 at 5:22 AM

Hi All!

I have the code to load the map from PostGIS database:

SharpMap.Layers.VectorLayer layHuyen = new SharpMap.Layers.VectorLayer("tbHuyen");

layHuyen.DataSource = new SharpMap.Data.Providers.PostGIS(PostGisConnectionString, "tbHuyen", "the_geom", "gid");

//Set up a line label layer

SharpMap.Layers.LabelLayer layLabel_Huyen = new SharpMap.Layers.LabelLayer("Huyen labels")
            {
                DataSource = layHuyen.DataSource,
                Enabled = true,
                LabelColumn = "elevation",
                MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest,
                LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection,               
                Style = new SharpMap.Styles.LabelStyle()
                {
                    ForeColor = System.Drawing.Color.White,
                    Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12),
                    BackColor = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 255, 0, 0)),
                    HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center,                   
                    MaxVisible = 90,
                    MinVisible = 30,
                    CollisionDetection = true
                }
            };

map.Layers.Add(layHuyen);

map.Layers.Add(layLabel_Huyen);

when I use the properties: MinVisible and MaxVisible ->data layers are not displayed on the map. Help.

 

 

 

Coordinator
May 11, 2012 at 10:05 AM

what is the extent of your dataset.

Labels will be shown if the WorldWidth of the map shown is between 30 and 90

Hth FObermaier

Editor
May 11, 2012 at 10:10 AM

Thanks for reply.

how to determine the extent of data?

Coordinator
May 11, 2012 at 2:13 PM
var pgHuyen = new SharpMap.Data.Providers.PostGIS(PostGisConnectionString, "tbHuyen", "the_geom", "gid");
var exHuyen = pgHuyen.GetExtents();

Hth FObermaier

Editor
May 14, 2012 at 4:18 AM

Thanks for reply.

this is my exten:

- exCot	{1,1 597518,1334497}	SharpMap.Geometries.BoundingBox
+		_centroid	null	SharpMap.Geometries.Point
+		_max	{POINT (597518 1334497)}	SharpMap.Geometries.Point
+		_min	{POINT (1 1)}	SharpMap.Geometries.Point
		Bottom	1.0	double
+		BottomLeft	{POINT (1 1)}	SharpMap.Geometries.Point
+		BottomRight	{POINT (597518 1)}	SharpMap.Geometries.Point
		Height	1334496.0	double
		IsValid	true	bool
		Left	1.0	double
		LongestAxis	1	uint
+		Max	{POINT (597518 1334497)}	SharpMap.Geometries.Point
+		Min	{POINT (1 1)}	SharpMap.Geometries.Point
		Right	597518.0	double
		Top	1334497.0	double
+		TopLeft	{POINT (1 1334497)}	SharpMap.Geometries.Point
+		TopRight	{POINT (597518 1334497)}	SharpMap.Geometries.Point
		Width	597517.0	double

How do I determine the value of max and minVisible?

Coordinator
May 14, 2012 at 1:50 PM

Those are values you have to figure out yourself.

The values you initially used are probably from an example with lat/lon coordinates thus having a width of max 360.
In that case 30 to 90 cause the layer to be rendered when the viewport's width of the map is in that range.

The world width is ~600.000, so you can start with perhaps min = 50.000 and max = 150.000

Hth FObermaier

Editor
May 15, 2012 at 10:57 AM

thanks, I'll try.