You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SmartJSONEditor edited this page Aug 9, 2017
·
4 revisions
Usage
Generates random location within a radius in meters around center coordinate. In order to use, create value transformer and choose to output latitude values. Copy and paste the generator or other value node and output the longitude.
varValueTransformer=function(){this.displayName="Random Location with Radius";this.shortDescription="Generates Latitude or Longitude values around center coordinate with radius in meters. "this.isEditingDisabled=true;this.infoUrl="https://github.com/SmartJSONEditor/PublicDocuments/wiki/ValueTransformer-RandomLocationWithRadius";this.parameters=function(){varmapDefaultValues={latitude: 8.0,longitude: 11.0,latitudeDelta: 0.0,longitudeDelta: 0.0,mapType: 0}varmapParameter={name: "locationMap",displayName: "Map Location",description: "Zoom and center region on map",type: "Map",defaultValue: mapDefaultValues};varradius={name: "radius",displayName: "Radius",description: "Select random radius in meters",type: "Number",defaultValue: 1000};varoutupsDefaultValues=[{name: "latitude",displayName: "Latitude",enabled: 1},{name: "longitude",displayName: "Longitude",enabled: 0}];varoutputsParameter={name: "output",displayName: "Output value of",description: "Select output option for plugin",type: "Options",defaultValue: outupsDefaultValues};return[mapParameter,radius,outputsParameter];};this.transform=function(inputValue,jsonValue,arrayIndex,parameters){varlatitude=parameters.locationMap.latitude;varlongitude=parameters.locationMap.longitude;varradius=parameters.radius;varr=radius/111300,y0=latitude,x0=longitude,u=Math.random(),v=Math.random(),w=r*Math.sqrt(u),t=2*Math.PI*v,x=w*Math.cos(t),y1=w*Math.sin(t),x1=x/Math.cos(y0)varnewLatitude=y0+y1varnewLongitude=x0+x1if(parameters.output[0].enabled==1){returnnewLatitude;}if(parameters.output[1].enabled==1){returnnewLongitude;}return"Error";};}functionsjeClass(){returnnewValueTransformer();}