Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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');
});
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");
});
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));
});
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([]);
});
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));
}
};
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;
}
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
);
}
}
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
);
}
}
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);
};
}