Search in sources :

Example 1 with JsObject

use of org.cesiumjs.cs.js.JsObject in project gwt-cs by iSergio.

the class Materials method applyPolylineOutlineMaterial.

public void applyPolylineOutlineMaterial(Polyline primitive) {
    JsObject jsOobject = JsObject.create();
    primitive.material = Material.fromType("PolylineOutline", JsObject.$(jsOobject, "outlineWidth", primitive.width / 2.0));
}
Also used : JsObject(org.cesiumjs.cs.js.JsObject)

Example 2 with JsObject

use of org.cesiumjs.cs.js.JsObject in project gwt-cs by iSergio.

the class Materials method applyPolylineGlowMaterial.

public void applyPolylineGlowMaterial(Polyline primitive) {
    JsObject jsOobject = JsObject.create();
    primitive.material = Material.fromType("PolylineGlow", JsObject.$(jsOobject, "innerWidth", primitive.width / 2.0));
}
Also used : JsObject(org.cesiumjs.cs.js.JsObject)

Example 3 with JsObject

use of org.cesiumjs.cs.js.JsObject in project gwt-cs by iSergio.

the class CirclePrimitive method getPositions.

public Cartesian3[] getPositions() {
    EllipsePositionsOptions options = new EllipsePositionsOptions();
    options.semiMajorAxis = getRadius();
    options.semiMinorAxis = getRadius();
    options.center = getCenter();
    options.granularity = granularity;
    options.rotation = 0;
    JsObject jsObject = EllipseGeometryLibrary.computeEllipsePositions(options, false, true);
    if (jsObject.getObject("outerPositions") == null) {
        return null;
    }
    List<Cartesian3> positions = new ArrayList<>();
    JsArray<Number> nativePositions = (JsArray<Number>) jsObject.getObject("outerPositions");
    for (int i = 0; i < nativePositions.length(); i += 3) {
        double x = JsObject.getNumber(nativePositions, i).doubleValue();
        double y = JsObject.getNumber(nativePositions, i + 1).doubleValue();
        double z = JsObject.getNumber(nativePositions, i + 2).doubleValue();
        positions.add(new Cartesian3(x, y, z));
    }
    return positions.toArray(new Cartesian3[positions.size()]);
}
Also used : EllipsePositionsOptions(org.cesiumjs.cs.core.options.EllipsePositionsOptions) JsObject(org.cesiumjs.cs.js.JsObject) JsArray(org.cesiumjs.cs.js.JsArray) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ArrayList(java.util.ArrayList)

Example 4 with JsObject

use of org.cesiumjs.cs.js.JsObject in project gwt-cs by iSergio.

the class CustomGeocoder method buildPanel.

@Override
public void buildPanel() {
    OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
    openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {

        @Override
        public Promise<JsObject, Void> function(String input) {
            String endpoint = "http://nominatim.openstreetmap.org/search?";
            String query = "format=json&q=" + input;
            String requestString = endpoint + query;
            Promise<JsObject, Void> promise = Resource.fetchJson(requestString);
            promise.then(new Fulfill<JsObject>() {

                @Override
                public void onFulfilled(JsObject value) {
                    JSONArray jsonArray = new JSONArray(value);
                    for (int i = 0; i < jsonArray.size(); i++) {
                        JSONObject jsonObject = jsonArray.get(i).isObject();
                        JSONArray bboxDegrees = jsonObject.get("boundingbox").isArray();
                        Rectangle destination = Rectangle.fromDegrees(Double.parseDouble(bboxDegrees.get(2).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(0).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(3).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(1).isString().toString().replace("\"", "")));
                        GeocoderResult geocoderResult = new GeocoderResult();
                        geocoderResult.displayName = jsonObject.get("display_name").isString().toString();
                        geocoderResult.destinationRectangle = destination;
                        jsonArray.set(i, new JSONObject((JsObject) (Object) geocoderResult));
                    }
                }
            });
            return promise;
        }
    };
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.geocoder = openStreetMapNominatimGeocoder;
    csVPanel = new ViewerPanel(viewerOptions);
    contentPanel.add(new HTML("<p>Example of a custom geocoder.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) JsObject(org.cesiumjs.cs.js.JsObject) JSONArray(com.google.gwt.json.client.JSONArray) Rectangle(org.cesiumjs.cs.core.Rectangle) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML) Promise(org.cesiumjs.cs.promise.Promise) JSONObject(com.google.gwt.json.client.JSONObject) Fulfill(org.cesiumjs.cs.promise.Fulfill) GeocoderResult(org.cesiumjs.cs.core.GeocoderResult)

Aggregations

JsObject (org.cesiumjs.cs.js.JsObject)4 JSONArray (com.google.gwt.json.client.JSONArray)1 JSONObject (com.google.gwt.json.client.JSONObject)1 HTML (com.google.gwt.user.client.ui.HTML)1 ArrayList (java.util.ArrayList)1 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)1 GeocoderResult (org.cesiumjs.cs.core.GeocoderResult)1 Rectangle (org.cesiumjs.cs.core.Rectangle)1 EllipsePositionsOptions (org.cesiumjs.cs.core.options.EllipsePositionsOptions)1 JsArray (org.cesiumjs.cs.js.JsArray)1 Fulfill (org.cesiumjs.cs.promise.Fulfill)1 Promise (org.cesiumjs.cs.promise.Promise)1 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)1 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)1