Beispiel #1
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)
}
Beispiel #2
0
func TestFmtFieldString(t *testing.T) {
	assert.Nil(t, fmtFieldString(nil, false))
	assert.Equal(t, `'Name: [name]'`, *fmtFieldString([]interface{}{"Name: ", mss.Field("[name]")}, true))
	assert.Equal(t, `'[foo] = \'[name]\''`, *fmtFieldString([]interface{}{mss.Field("[foo]"), " = '", mss.Field("[name]"), "'"}, true))

}