-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for dynamic point styles in builtin viewer. fixed polygon col…
…ors not being shown in builtin layer viewer toggle. closes #146
- Loading branch information
Showing
8 changed files
with
139 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
package style | ||
|
||
type Transition struct { | ||
} | ||
type Transition struct{} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package server_test | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"net/http/httptest" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/dimfeld/httptreemux" | ||
"github.com/terranodo/tegola/mapbox/style" | ||
"github.com/terranodo/tegola/server" | ||
) | ||
|
||
func TestHandleMapStyle(t *testing.T) { | ||
// config params this test relies on | ||
server.HostName = serverHostName | ||
|
||
// setup a new provider | ||
testcases := []struct { | ||
handler http.Handler | ||
uri string | ||
uriPattern string | ||
reqMethod string | ||
expected style.Root | ||
}{ | ||
{ | ||
handler: server.HandleMapStyle{}, | ||
uri: fmt.Sprintf("/maps/%v/style.json", testMap.Name), | ||
uriPattern: "/maps/:map_name/style.json", | ||
reqMethod: "GET", | ||
expected: style.Root{ | ||
Name: testMap.Name, | ||
Version: style.Version, | ||
Center: [2]float64{testMap.Center[0], testMap.Center[1]}, | ||
Zoom: testMap.Center[2], | ||
Sources: map[string]style.Source{ | ||
testMap.Name: style.Source{ | ||
Type: style.SourceTypeVector, | ||
URL: fmt.Sprintf("http://%v/capabilities/%v.json", serverHostName, testMap.Name), | ||
}, | ||
}, | ||
Layers: []style.Layer{ | ||
{ | ||
ID: testLayer1.Name, | ||
Source: testMap.Name, | ||
SourceLayer: testLayer1.Name, | ||
Type: style.LayerTypeCircle, | ||
Layout: &style.LayerLayout{ | ||
Visibility: "visible", | ||
}, | ||
Paint: &style.LayerPaint{ | ||
CircleRadius: 3, | ||
CircleColor: "#7a40ce", | ||
}, | ||
}, | ||
{ | ||
ID: testLayer2.Name, | ||
Source: testMap.Name, | ||
SourceLayer: testLayer2.Name, | ||
Type: style.LayerTypeLine, | ||
Layout: &style.LayerLayout{ | ||
Visibility: "visible", | ||
}, | ||
Paint: &style.LayerPaint{ | ||
LineColor: "#7b40ce", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for i, tc := range testcases { | ||
var err error | ||
|
||
// setup a new router. this handles parsing our URL wildcards (i.e. :map_name, :z, :x, :y) | ||
router := httptreemux.New() | ||
// setup a new router group | ||
group := router.NewGroup("/") | ||
group.UsingContext().Handler(tc.reqMethod, tc.uriPattern, tc.handler) | ||
|
||
r, err := http.NewRequest(tc.reqMethod, tc.uri, nil) | ||
if err != nil { | ||
t.Errorf("test case (%v) failed: %v", i, err) | ||
continue | ||
} | ||
|
||
w := httptest.NewRecorder() | ||
router.ServeHTTP(w, r) | ||
|
||
if w.Code != http.StatusOK { | ||
t.Errorf("test case (%v). handler returned wrong status code: got (%v) expected (%v)", i, w.Code, http.StatusOK) | ||
} | ||
|
||
var output style.Root | ||
if err = json.NewDecoder(w.Body).Decode(&output); err != nil { | ||
t.Errorf("test case (%v) failed: %v", i, err) | ||
continue | ||
} | ||
|
||
if !reflect.DeepEqual(output, tc.expected) { | ||
t.Errorf("test case (%v) failed. output \n\n %+v \n\n does not match expected \n\n %+v", i, output, tc.expected) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters