Example #1
0
func TestScaledLineStringLayer(t *testing.T) {
	m := New(&locator)
	m.SetNoMapBlock(true)

	m.AddLayer(mml.Layer{ID: "test", SRS: "4326", Type: mml.LineString, ScaleFactor: 2.0},
		[]mss.Rule{
			{Layer: "test", Properties: mss.NewProperties(
				"line-width", 3.0,
				"line-opacity", 0.2,
				"line-dasharray", []mss.Value{2.0, 7.0},
			)},
		})
	m.AddLayer(mml.Layer{ID: "test", SRS: "4326", Type: mml.LineString},
		[]mss.Rule{
			{Layer: "test", Properties: mss.NewProperties(
				"line-width", 1.0,
				"line-color", color.MustParse("red"),
				"line-opacity", 0.5,
				"line-dasharray", []mss.Value{3.0, 5.0},
			)},
		})
	result := m.String()
	assert.Contains(t, result, "WIDTH 6\n")
	assert.Contains(t, result, "OPACITY 20\n")
	assert.Regexp(t, `PATTERN\s+4\s+14\s+END`, result)

	assert.Contains(t, result, "WIDTH 1\n")
	assert.Contains(t, result, "COLOR \"#ff0000\"\n")
	assert.Contains(t, result, "OPACITY 50\n")
	assert.Regexp(t, `PATTERN\s+3\s+5\s+END`, result)
}
Example #2
0
func TestPolygonLayer(t *testing.T) {
	m := New(&locator)
	m.SetNoMapBlock(true)

	m.AddLayer(mml.Layer{ID: "test", SRS: "4326", Type: mml.Polygon},
		[]mss.Rule{
			{Layer: "test", Properties: mss.NewProperties(
				"line-width", 1.0,
				"line-color", color.MustParse("red"),
				"line-opacity", 0.5,
				"line-dasharray", []mss.Value{3.0, 5.0},
				"polygon-fill", color.MustParse("blue"),
				"polygon-opacity", 0.2,
				"text-size", 10.0,
				"text-name", []mss.Value{mss.Field("name")},
			)},
		})
	result := m.String()
	assert.Contains(t, result, "WIDTH 1\n")
	assert.Contains(t, result, "OUTLINECOLOR \"#ff000080\"\n")
	assert.Regexp(t, `PATTERN\s+3\s+5\s+END`, result)
	assert.Contains(t, result, "COLOR \"#0000ff\"\n")
	assert.Contains(t, result, "OPACITY 20\n")
	assert.Regexp(t, `LABEL\s+ SIZE 7.4\d+`, result)
	assert.Regexp(t, `TEXT 'name'`, result)
}
Example #3
0
func TestMarkerTransformWithRotationPoint(t *testing.T) {
	m := New(&locator)
	m.SetNoMapBlock(true)
	m.AddLayer(mml.Layer{ID: "test", SRS: "4326", Type: mml.Point},
		[]mss.Rule{
			{Layer: "test", Properties: mss.NewProperties(
				"marker-file", "/foo/bar.svg",
				"marker-transform", "translate(0.000000, -10.000000) scale(0.500000) rotate(345.000000, 0.000000, 20.000000)",
				"marker-width", 40.0,
				"marker-height", 40.0,
			)},
		})
	result := m.String()

	assert.Contains(t, result, `SYMBOL "anchor-0-5-1-foo-bar-svg"`)
	assert.Contains(t, result, `ANCHORPOINT 0.5 1`)
	assert.Contains(t, result, `ANGLE -345`)
	assert.Contains(t, result, `SIZE 20`)
}