OpenLayers baselayer (OSM) is not as smooth as osm.org - openlayers-6

I am new into OpenLayers and setting my hands on it. I have added baselayer (osm). But i have noticed that the OpenLayers base layer is not as smooth as org.com. When I try to zoom in and out there is step zooming and osm.org has just 18 zoom level and OpenLayers has more than that. I want exact same smoothness and less zoom level.
var gridsetName = "EPSG:900913";
var gridNames = ['EPSG:900913:0', 'EPSG:900913:1', 'EPSG:900913:2', 'EPSG:900913:3', 'EPSG:900913:4', 'EPSG:900913:5', 'EPSG:900913:6', 'EPSG:900913:7', 'EPSG:900913:8', 'EPSG:900913:9', 'EPSG:900913:10', 'EPSG:900913:11', 'EPSG:900913:12', 'EPSG:900913:13', 'EPSG:900913:14', 'EPSG:900913:15', 'EPSG:900913:16', 'EPSG:900913:17', 'EPSG:900913:18', 'EPSG:900913:19', 'EPSG:900913:20', 'EPSG:900913:21', 'EPSG:900913:22', 'EPSG:900913:23', 'EPSG:900913:24', 'EPSG:900913:25', 'EPSG:900913:26', 'EPSG:900913:27', 'EPSG:900913:28', 'EPSG:900913:29', 'EPSG:900913:30'];
var baseUrl = "http://localhost:8080/geoserver/gwc/service/wmts";
var style = "";
var format = "application/vnd.mapbox-vector-tile";
var projection = new Projection({
code: "EPSG:900913",
units: "m",
axisOrientation: "neu",
});
var layerCache = {};
var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625, 4891.9698095703125, 2445.9849047851562, 1222.9924523925781, 611.4962261962891, 305.74811309814453, 152.87405654907226, 76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508, 2.388657133579254, 1.194328566789627, 0.5971642833948135, 0.2985821416974068, 0.1492910708487034, 0.0746455354243517, 0.0373227677121758, 0.0186613838560879, 0.009330691928044, 0.004665345964022, 0.002332672982011, 0.0011663364910055, 5.831682455027E-4, 2.915841227514E-4, 1.457920613757E-4];
var view = new View({
center: [0, 0],
zoom: 2,
resolution: resolutions,
projection: projection,
extent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
});
var map = new Map({
layers: [
new TileLayer({
preload: Infinity,
source: new OSM({ cacheSize: 20000 }),
}),
],
target: "map",
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true,
view: view,
});
map
.getView()
.fit([-20037508.34, -20037508.34, 20037508.34, 20037508.34], map.getSize());

To restrict the zoom to 18 levels you will need to specify maxZoom in the view options, and in OpenLayers 6 you will need to specify multiWorld: true to get to zoom 0. You can also constrain to integer zoom levels, etc.
var view = new View({
center: [0, 0],
zoom: 2,
maxZoom: 18,
multiWorld: true,
constrainResolution: true,
smoothResolutionConstraint: false,
});
You can also set options for the map interactions to vary the duration of the zoom animation, for example:
interactions: defaultInteractions({zoomDuration: 100}),

Related

Imported mesh falls through the ground in BabylonJS

I'm trying to use physics (AmmoJS) in BabylonJS for an imported mesh.
For meshes I create on the fly everything works fine, but when I import a mesh it falls through the ground.
const ground = BABYLON.MeshBuilder.CreateBox("ground",
{ width: 10, height: 1, depth: 10}, scene);
ground.receiveShadows = true;
ground.checkCollisions = true;
ground.physicsImpostor = new BABYLON.PhysicsImpostor(ground , BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, friction: 0.5, restitution: 0.5 }, scene);
BABYLON.SceneLoader.ImportMesh(["car9"], "models/", "Policecar.glb", scene, function (meshes, particleSystems, skeletons) {
for (let i in meshes) {
meshes[i].checkCollisions = true;
}
let policecar = meshes[0];
policecar.physicsImpostor = new BABYLON.PhysicsImpostor(policecar, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 10, friction: 0.5, restitution: 0.5 });
policecar.position = new BABYLON.Vector3(0, 10, 0);
policecar.scaling = new BABYLON.Vector3(scale, scale, scale);
});
When I change the restition of the policecar to 0 or 1, it doesn't fall through the ground, but bounces weirdly a few times and falls on it's side. With a BoxImpostor instead of MeshImpostor it falls straight through.
Any ideas?
You have to consider that .glb-files use right handed system, while BabylonJS uses left handed system. So I would recommend to set BabylonJS to right handed and don't scale by absolute values.
scene.useRightHandedSystem = true;
...
policecar.scaling.scaleInPlace(scale);

WebRTC AGC (Automatic Gain Control): can it really be disabled?

:)
I've installed AppRTC (https://github.com/webrtc/apprtc) to a separate server to try out more flexible control of the WebRTC parameters.
The main task is to disable Automatic Gain Control (AGC).
The following steps have been performed:
The parameters for the audio-stream:
{
video:
{
frameRate: 30,
width: 640,
height: 480
},
audio:
{
echoCancellation: true,
noiseSuppression: true,
autoGainControl: false
}
}
The GainNode filter has been added via audioContext.createGain() and has received a fixed value via gainNode.gain.value
To be able to test the AGC absence - a graphical audio meter has been added using audioContext.createScriptProcessor(...).onaudioprocess
The problem is that in fact the AGC is not disabled and Gain still remains dynamic.
During a long monotone loud sound the analyzer drops to a significantly lower value after 5-6 seconds.
And after 5-6 seconds of silence gets back to previous range.
All this has been tested on macOs Catalina 10.15.7, in the following browsers:
Mozilla Firefox 82.0.3,
Google Chrome 86.0.4240.198,
Safari 14.0 (15610.1.28.1.9, 15610),
and also on iOS 14.2 Safari.
The question: is there a functioning possibility to turn off AGC and to follow that not only "by hearing" but also by the meter values?
The full code of the gain fixation method:
src/web_app/html/index_template.html
var loadingParams = {
errorMessages: [],
isLoopback: false,
warningMessages: [],
roomId: '101',
roomLink: 'https://www.xxxx.com/r/101',
// mediaConstraints: {"audio": true, "video": true},
mediaConstraints: {video: {frameRate: 30, width: 640, height: 480}, audio: {echoCancellation: true, noiseSuppression: true, autoGainControl: false}},
offerOptions: {},
peerConnectionConfig: {"bundlePolicy": "max-bundle", "iceServers": [{"urls": ["turn:www.xxxx.com:3478?transport=udp", "turn:www.xxxx.com:3478?transport=tcp"], "username": "demo", "credential": "demo"}, {"urls": ["stun:www.xxxx.com:3478"], "username": "demo", "credential": "demo"}], "rtcpMuxPolicy": "require"},
peerConnectionConstraints: {"optional": []},
iceServerRequestUrl: 'https://www.xxxx.com//v1alpha/iceconfig?key=',
iceServerTransports: '',
wssUrl: 'wss://www.xxxx.com:8089/ws',
wssPostUrl: 'https://www.xxxx.com:8089',
bypassJoinConfirmation: false,
versionInfo: {"time": "Wed Sep 23 12:49:00 2020 +0200", "gitHash": "78600dbe205774c115cf481a091387d928c99d6a", "branch": "master"},
};
src/web_app/js/appcontroller.js
AppController.prototype.gainStream = function (stream, gainValue) {
var max_level_L = 0;
var old_level_L = 0;
var cnvs = document.createElement('canvas');
cnvs.style.cssText = 'position:fixed;width:320px;height:30px;z-index:100;background:#000';
document.body.appendChild(cnvs);
var cnvs_cntxt = cnvs.getContext("2d");
var videoTracks = stream.getVideoTracks();
var context = new AudioContext();
var mediaStreamSource = context.createMediaStreamSource(stream);
var mediaStreamDestination = context.createMediaStreamDestination();
var gainNode = context.createGain();
var javascriptNode = context.createScriptProcessor(1024, 1, 1);
mediaStreamSource.connect(gainNode);
mediaStreamSource.connect(javascriptNode);
gainNode.connect(mediaStreamDestination);
javascriptNode.connect(mediaStreamDestination);
javascriptNode.onaudioprocess = function(event){
var inpt_L = event.inputBuffer.getChannelData(0);
var instant_L = 0.0;
var sum_L = 0.0;
for(var i = 0; i < inpt_L.length; ++i) {
sum_L += inpt_L[i] * inpt_L[i];
}
instant_L = Math.sqrt(sum_L / inpt_L.length);
max_level_L = Math.max(max_level_L, instant_L);
instant_L = Math.max( instant_L, old_level_L -0.008 );
old_level_L = instant_L;
cnvs_cntxt.clearRect(0, 0, cnvs.width, cnvs.height);
cnvs_cntxt.fillStyle = '#00ff00';
cnvs_cntxt.fillRect(10,10,(cnvs.width-20)*(instant_L/max_level_L),(cnvs.height-20)); // x,y,w,h
}
gainNode.gain.value = gainValue;
var controlledStream = mediaStreamDestination.stream;
for (const videoTrack of videoTracks) {
controlledStream.addTrack(videoTrack);
}
return controlledStream;
};
AppController.prototype.onLocalStreamAdded_ = function(stream) {
trace('User has granted access to local media.');
this.localStream_ = this.gainStream(stream, 100);
this.infoBox_.getLocalTrackIds(this.localStream_);
if (!this.roomSelection_) {
this.attachLocalStream_();
}
};
Thank you!
Best Regards,
Andrei Costenco
I think the problem you ran into is that echoCancellation and noiseSuppression do modify the signal as well. Since you mentioned that you are using a long monotone sound to test your code it could very well be that the noiseSuppression algorithm tries to reduce that "noise".
Unfortunately there is no way to tell why the signal was modified. You have to trust the browser here that it actually has switched off the gain control and that all remaining modifications come from the other two algorithms.
If you don't want to fully trust the browser you could also experiment a bit by using other sounds to run your tests. It should not be "noisy" but it's difficult to say what get's detected by the browser as noise and what doesn't.

Load Local Geojson Data with Leaflet and Vue.js

I am displaying in my Vue.js a leaflet Map with Geojson Data.
var map = L.map('map').setView([13.82, 106.62], 5);
// load a tile layer
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
attribution: 'Tiles by MAPC, Data by MassGIS',
maxZoom: 17,
minZoom: 6
}).addTo(map);
// The rodents json data need to be replace by a proper HTTPS not local Server
map.setZoom(4);
$.getJSON("C:\Users\simon\Desktop\FE\data\heat.geojson",function(data){
var locations = data.features.map(function(gps) {
// the heatmap plugin wants an array of each location
var location = gps.geometry.coordinates.reverse();
location.push(1.0);
return location; // e.g. [50.5, 30.5, 0.2], // lat, lng, intensity
});
var heat = L.heatLayer(locations, { radius: 25, maxOpacity: .8, scaleRadius: false, valueField: 'total',
// gradient: {
// 0.0: 'green',
// 0.5: 'yellow',
// 1.0: 'red'
// }
});
map.addLayer(heat);
});
On a local browser, I will simply load the data from the file location and it will work. How can I load the data in my local vue.js application?\
If i Change path to : HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
(XHR)GET - http://localhost:8082/pages/..FE/data/sales_vietnam_heat.geojson

How do I a line to dreamweaver that I drew on Geojson.io?

The code below is what I am using. Basically modified from the polygons I was drawing, but the lines arent showing up...
// Construct the Venue Line.
theVenue = new google.maps.LineString({
paths: outlineCoords,
strokeColor: '#ffba20',
strokeOpacity: 1,
strokeWeight: 2,
fillColor: '#ffba20',
fillOpacity: 1
});
// ...
theVenue.setMap(map);
// outline the venue
var theVenue;
// Define the LatLng coordinates for the polygon's path.
var outlineCoords = [new google.maps.LatLng(39.9066747476479, -75.2781808376312),
new google.maps.LatLng(39.9083124955562, -75.2793931961059),
new google.maps.LatLng(39.910123025565, -75.2808094024658),

OpenLayer OpenStreetMap Vector Size independent of Zoom

I have a VectorLayer over my OSM and I have successfully plotted a polygon on my Map.However what is happening is that the polygon is getting too large in size as I zoom in or getting small in size as I zoom out. Is there a way to keep the size of the polygon independent of zoom?
Here is my code for plotting the circle
map = new OpenLayers.Map("container");
var mapnik = new OpenLayers.Layer.OSM();
epsg4326 = new OpenLayers.Projection("EPSG:4326");
var zoom = 6;
map.addLayer(mapnik);
map.addControl(new OpenLayers.Control.DragPan());
projectTo = map.getProjectionObject();
var lonLat = new OpenLayers.LonLat(-82.56,43.67611).transform(epsg4326, projectTo);
map.setCenter(lonLat, zoom);
var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults(
{fillColor: "black", fillOpacity: 0.5, strokeColor: "black"},
OpenLayers.Feature.Vector.style["default"]));
var vectorLayer = new OpenLayers.Layer.Vector("Overlay", {styleMap: styleMap});
var point = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat);
var mycircle = OpenLayers.Geometry.Polygon.createRegularPolygon
(
point,
50000,
50,
0
);
var featurecircle = new OpenLayers.Feature.Vector(mycircle);
vectorLayer.addFeatures([featurecircle]);
map.addLayer(vectorLayer);