How to use the terriajs-cesium/Source/Core/Rectangle.fromDegrees function in terriajs-cesium

To help you get started, we’ve selected a few terriajs-cesium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TerriaJS / terriajs / lib / Models / WebMapServiceCatalogItem.js View on Github external
function getRectangleFromLayer(layer) {
    var egbb = layer.EX_GeographicBoundingBox; // required in WMS 1.3.0
    if (defined(egbb)) {
        return Rectangle.fromDegrees(egbb.westBoundLongitude, egbb.southBoundLatitude, egbb.eastBoundLongitude, egbb.northBoundLatitude);
    } else {
        var llbb = layer.LatLonBoundingBox; // required in WMS 1.0.0 through 1.1.1
        if (defined(llbb)) {
            return Rectangle.fromDegrees(llbb.minx, llbb.miny, llbb.maxx, llbb.maxy);
        }
    }
    return undefined;
}
github TerriaJS / terriajs / test / Models / CsvCatalogItemSpec.js View on Github external
it('can update from json', function() {
        var dataStr = 'col1, col2\ntest, 0';
        csvItem.updateFromJson({
            name: 'Name',
            description: 'Description',
            rectangle: [-10, 10, -20, 20],
            url: 'http://my.csv.com/test.csv',
            data: dataStr,
            dataSourceUrl: 'none',
            dataCustodian: 'Data Custodian',
        });

        expect(csvItem.name).toBe('Name');
        expect(csvItem.description).toBe('Description');
        expect(csvItem.rectangle).toEqual(Rectangle.fromDegrees(-10, 10, -20, 20));
        expect(csvItem.type).toBe('csv');
        expect(csvItem.url.indexOf('http://my.csv.com/test.csv')).toBe(0);
        expect(csvItem.data.indexOf(dataStr)).toBe(0);
        expect(csvItem.dataCustodian).toBe('Data Custodian');
        expect(csvItem.dataSourceUrl).toBe('none');
    });
github TerriaJS / terriajs / test / Models / SdmxJsonCatalogItemSpec.js View on Github external
it("can update from json", function() {
    item.updateFromJson({
      name: "Name",
      description: "Description",
      rectangle: [-10, 10, -20, 20],
      url: "http://foo.bar",
      dataUrlComponent: "atad"
    });
    expect(item.name).toBe("Name");
    expect(item.description).toBe("Description");
    expect(item.rectangle).toEqual(Rectangle.fromDegrees(-10, 10, -20, 20));
    expect(item.type).toBe("sdmx-json");
    expect(item.url.indexOf("http://foo.bar")).toBe(0);
    expect(item.dataUrlComponent).toBe("atad");
  });
github TerriaJS / terriajs / test / Models / CameraViewSpec.js View on Github external
y: 10.0,
          z: 20.0
        },
        direction: {
          x: -1.0,
          y: 0.1,
          z: 0.2
        },
        up: {
          x: 0.0,
          y: 1.0,
          z: 0.1
        }
      });

      expect(view.rectangle).toEqual(Rectangle.fromDegrees(45, -20, 55, -10));
      expect(view.position).toEqual(new Cartesian3(10000000, 10, 20));
      expect(view.direction).toEqual(new Cartesian3(-1.0, 0.1, 0.2));
      expect(view.up).toEqual(new Cartesian3(0.0, 1.0, 0.1));
    });
github TerriaJS / terriajs / test / Models / WebMapServiceCatalogItemSpec.js View on Github external
dataUrl: 'http://my.wfs.com/wfs',
            dataCustodian: 'Data Custodian',
            metadataUrl: 'http://my.metadata.com',
            url: 'http://my.wms.com',
            layers: 'mylayer',
            parameters: {
                custom: true,
                awesome: 'maybe'
            },
            tilingScheme: new WebMercatorTilingScheme(),
            getFeatureInfoFormats: []
        });

        expect(wmsItem.name).toBe('Name');
        expect(wmsItem.description).toBe('Description');
        expect(wmsItem.rectangle).toEqual(Rectangle.fromDegrees(-10, 10, -20, 20));
        expect(wmsItem.legendUrl).toBe('http://legend.com');
        expect(wmsItem.dataUrlType).toBe('wfs');
        expect(wmsItem.dataUrl.indexOf('http://my.wfs.com/wfs')).toBe(0);
        expect(wmsItem.dataCustodian).toBe('Data Custodian');
        expect(wmsItem.metadataUrl).toBe('http://my.metadata.com');
        expect(wmsItem.url).toBe('http://my.wms.com');
        expect(wmsItem.layers).toBe('mylayer');
        expect(wmsItem.parameters).toEqual({
            custom: true,
            awesome: 'maybe'
        });
        expect(wmsItem.tilingScheme instanceof WebMercatorTilingScheme).toBe(true);
        expect(wmsItem.getFeatureInfoFormats).toEqual([]);
    });
github TerriaJS / terriajs / lib / Models / CameraView.js View on Github external
CameraView.fromJson = function(json) {
    if (definedNotNull(json.lookAt)) {
        var targetPosition = Cartographic.fromDegrees(json.lookAt.targetLongitude, json.lookAt.targetLatitude, json.lookAt.targetHeight);
        var headingPitchRange = new HeadingPitchRange(CesiumMath.toRadians(json.lookAt.heading), CesiumMath.toRadians(json.lookAt.pitch), json.lookAt.range);
        return CameraView.fromLookAt(targetPosition, headingPitchRange);
    } else if (definedNotNull(json.positionHeadingPitchRoll)) {
        var cameraPosition = Cartographic.fromDegrees(json.positionHeadingPitchRoll.cameraLongitude, json.positionHeadingPitchRoll.cameraLatitude, json.positionHeadingPitchRoll.cameraHeight);
        return CameraView.fromPositionHeadingPitchRoll(cameraPosition,
            CesiumMath.toRadians(json.positionHeadingPitchRoll.heading),
            CesiumMath.toRadians(json.positionHeadingPitchRoll.pitch),
            CesiumMath.toRadians(json.positionHeadingPitchRoll.roll));
    } else if (definedNotNull(json.position) && definedNotNull(json.direction) && definedNotNull(json.up)) {
        return new CameraView(
            Rectangle.fromDegrees(json.west, json.south, json.east, json.north),
            new Cartesian3(json.position.x, json.position.y, json.position.z),
            new Cartesian3(json.direction.x, json.direction.y, json.direction.z),
            new Cartesian3(json.up.x, json.up.y, json.up.z));
    } else {
        return new CameraView(Rectangle.fromDegrees(json.west, json.south, json.east, json.north));
    }
};
github TerriaJS / terriajs / lib / Models / ArcGisMapServerCatalogGroup.js View on Github external
content: topLevelJson.description
        });
    }

    if (layer.description && layer.description.length > 0) {
        result.info.push({
            name: 'Data Description',
            content: layer.description
        });
    }

    var extent = layer.extent;
    if (defined(extent) && extent.spatialReference && extent.spatialReference.wkid) {
        var wkid = extent.spatialReference.wkid;
        if (wkid === 4326 || wkid === 4283) {
            result.rectangle = Rectangle.fromDegrees(extent.xmin, extent.ymin, extent.xmax, extent.ymax);
        } else if (wkid === 3857 || wkid === 900913 || wkid === 102100) {
            var projection = new WebMercatorProjection();
            var sw = projection.unproject(new Cartesian3(extent.xmin, extent.ymin, 0.0));
            var ne = projection.unproject(new Cartesian3(extent.xmax, extent.ymax, 0.0));
            result.rectangle = new Rectangle(sw.longitude, sw.latitude, ne.longitude, ne.latitude);
        }
    }

    if (typeof(mapServiceGroup.itemProperties) === 'object') {
        Object.keys(mapServiceGroup.itemProperties).forEach(function(k) {
            result[k] = mapServiceGroup.itemProperties[k];
        });
    }

    return result;
}
github TerriaJS / terriajs / lib / Models / TableDataSource.js View on Github external
longitudeColumn.values[i],
                latitudeColumn.values[i],
                defined(heightColumn) ? heightColumn.values[i] : undefined
            );
            setEntityProperties(entity, rowObject, tableStructure.getColumnAliases());

            var value = defined(tableColumn) ? tableColumn.indicesOrValues[i] : undefined;
            var color = legendHelper.getColorFromValue(value);
            var scale = legendHelper.getScaleFromValue(value);
            entity.availability = timeColumn && timeColumn.availabilities && timeColumn.availabilities[i];
            var show = calculateShow(entity.availability);
            addPointToEntity(entity, tableColumnStyle, scale, color, show);
            dataSource._entityCollection.add(entity);
        }

        dataSource._extent = Rectangle.fromDegrees(
            longitudeColumn.minimumValue, latitudeColumn.minimumValue, longitudeColumn.maximumValue, latitudeColumn.maximumValue
        );
    }
}
github TerriaJS / terriajs / lib / Map / TableDataSource2.js View on Github external
entity.billboard = {
                    horizontalOrigin : HorizontalOrigin.CENTER,
                    verticalOrigin : VerticalOrigin.BOTTOM,
                    image : tableStyle.imageUrl,
                    scale : scale,
                    color : color,
                    show : show
                };
            }
            dataSource._entityCollection.add(entity);
        }

        dataSource._changed.raiseEvent(dataSource);
        updateClock(dataSource);

        dataSource._extent = Rectangle.fromDegrees(
            longitudeColumn.minimumValue, latitudeColumn.minimumValue, longitudeColumn.maximumValue, latitudeColumn.maximumValue
        );
    }
}
github TerriaJS / terriajs / lib / Models / BingMapsSearchProvider.ts View on Github external
function createZoomToFunction(model: BingMapsSearchProvider, resource: any) {
  const [south, west, north, east] = resource.bbox;
  const rectangle = Rectangle.fromDegrees(west, south, east, north);

  return function() {
    const terria = model.terria;
    terria.currentViewer.zoomTo(rectangle, model.flightDurationSeconds);
  };
}