FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SharpMap/Examples/ExampleCodeSnippets/ClipLabelPosition.cs at v1/main · SharpMap/SharpMap · GitHub
SharpMap
SharpMap
Repository navigation
Code
Issues
42
(42)
Pull requests
6
(6)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
SharpMap
/
Examples
/
ExampleCodeSnippets
/
ClipLabelPosition.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (36 loc) · 1.36 KB
Breadcrumbs
SharpMap
/
Examples
/
ExampleCodeSnippets
/
ClipLabelPosition.cs
Copy path
File metadata and controls
39 lines (36 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace
ExampleCodeSnippets
{
/// <summary>
/// A clipping utility that ensures every geometry is labeled within the current map viewport
/// </summary>
public
class
ClipLabelPosition
{
private
GeoAPI
.
Geometries
.
IGeometry
_clip
;
private
GeoAPI
.
Geometries
.
Prepared
.
IPreparedGeometry
_prepClip
;
/// <summary>
/// Creates an instance of this class
/// </summary>
/// <param name="map">A map</param>
public
ClipLabelPosition
(
SharpMap
.
Map
map
)
{
map
.
MapViewOnChange
+=
(
)
=>
{
_clip
=
map
.
Factory
.
ToGeometry
(
map
.
Envelope
)
;
_prepClip
=
NetTopologySuite
.
Geometries
.
Prepared
.
PreparedGeometryFactory
.
Prepare
(
_clip
)
;
}
;
}
/// <summary>
/// A <see cref="SharpMap.Layers.LabelLayer.GetLocationMethod"/> implementation that clips
/// a feature's geometry to the current viewport of the map
/// </summary>
/// <param name="row">A feature</param>
/// <returns>A label position</returns>
public
GeoAPI
.
Geometries
.
Coordinate
GetClippedPosition
(
SharpMap
.
Data
.
FeatureDataRow
row
)
{
var
g
=
_prepClip
.
Contains
(
row
.
Geometry
)
?
row
.
Geometry
:
_clip
.
Intersection
(
row
.
Geometry
)
;
return
g
.
InteriorPoint
.
Coordinate
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL