geoJSON location/geometry instance - geojson

I have a JSON file describing a business and the location is specified in GEOJSON. Without using FEATURE, I just want to specify that the location is always a GEOJSON geometry. So for the following instance do I need to use the phrase "geometry"? or Can I use any phrase such as "GeometryInstance" or "InstanceLocation" instead of the phrase "geometry"?
"geometry":{"type": "Polygon", "coordinates": [
[
[
143.6033048818323,
-38.76987023813212
],
[
143.605236072323,
-38.76966947968941
],
[
143.60497858025758,
-38.76839799643248
],
[
143.6029830167505,
-38.768615488596204
],
[
143.6033048818323,
-38.76987023813212
]
]
]}

Related

GeoJSON polygons on import into ArcGIS Web are always solid filled, instead of the transparency/opacity styles we set for geoJson

I've been playing with GeoJSON only recently, and was wanting to request some assistance on the below:
We save the graphitems (polygon rings, etc), from the web maps.
We then convert it to a GeoJSON file for export, along with styles for transparency/opacity (see code further below).
We then send the exported GeoJSON file for import into ArcGIS.
The file is imported successfully, but the, colour or transparency/opacity is not being set, it defaults to 20% opacity.
Is there a way to honour the transparency/opacity for GeoJSON imports into ArcGIS?
Am I setting up the styles incorrectly in the GeoJSON file?
Sample GeoJson file is as per below:
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "EPSG:3857"
}
},
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
15576024.93758691,
-4055443.47590715
],
[
15576028.52057261,
-4055971.3691337
],
[
15576624.49052747,
-4055960.6201765984
],
[
15576618.518884636,
-4055442.281578583
],
[
15576024.93758691,
-4055443.47590715
]
]
]
},
"properties": {
"id": 13,
"centerPoint": [
-34.20013348612295,
139.9245056104621
],
"address": "Golden Heights, South Australia",
"title": "Golden Heights, South Australia",
"area": 21.232800390625002
},
"style": {
"fill": "blue",
"stroke-width": "3",
"fill-opacity": 0.5
}
}
]
}
Any help on the above would be much appreciated.
Thanks.
Esri layers use the Renderer property to determine how to render features. If you're looking for a generic solution that will work with any geojson, I'm not sure there's an easy way to transform svg-style css classes into an esri renderer. For your case, it looks like you need a SimpleRenderer whose symbol is a SimpleFillSymbol. I don't think there's a shortcut to use css properties from your JSON to tell the api how to create a renderer. This could be a great idea for a plugin, but on the other hand, a small list of simple css classes doesn't have the same capacity to render features at the level of complexity that a Renderer allows for, so I'm not sure how you could even map those css properties to the renderer propeties.
I would also try asking this question on esri's geonet forum - that forum has way more knowledge and activity when it comes to the arcgis js api than SO does.

Make electron app smaller?

I just recently built an electron app and packaged it using electron-packager. The .exe file is 55,000kb and the rest of the folder is quite bulky as well. Is there any way to take down the size of this application at all?
Here's a github issue on it.
The comment I'm emphasizing is:
That's the expected size, there is no way to make it smaller.
The reason why it's so big is because electron is loading most of chromium inside that 50mb file.
So no unfortunately there is no way to make it smaller sorry.
A somewhat helpful post from that github thread suggests removing unnecessary node modules via electron-packager. It also offers a bit more explanation on why files are so large.
You can zip your app and if you're using electron-packager you can ignore some node modules that you don't need when the app is running, this makes it a bit smaller. For instance I have a 37MB zipped Electron app (Note Windows version is much larger as it contains a copy of Git). But Electron will always have a large part of Chrome in it so there is only so much that can be done. Electron itself right now is ~33MB.
There is a way to reduce Electron size drastically (up to 99%, depending how big is your app), by using native browser, available in each OS, instead of loading webkit. BUT as built in browsers don't have the system API's, you will also be drastically limited in what you can do. But, if you need basic web ui app, this might be the best solution out there, though, it must be mentioned, that it might have some unexpected issues, as you will need to test your app on different OS'es browsers..
The method i'm talking about is available in awesome post Put your Electron app on a diet with Electrino by Pauli Olavi Ojala
If you are using Electron Builder https://www.electron.build you should use the various methods listed to remove files and folders for specific platforms.
Example
{
"name": "Example",
"version": "1.1.2",
"description": "",
"main": "main.js",
"scripts": {},
"build": {
"appId": "com.example",
"afterSign": "notarize.js",
"fileAssociations": [{
"ext": [
"mp4"
],
"name": "Media File",
"role": "Viewer"
}],
"dmg": {
"sign": true
},
"mac": {
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist",
"icon": "build/icon.png",
"category": "public.app-category.video",
"extraFiles": [{
"from": "resources/bin/mac",
"to": "Resources/bin/mac",
"filter": [
"**/*"
]
},
{
"from": "node_modules/platforms/darwin-x64/bin",
"to": "Resources/bin/mac",
"filter": [
"**/*"
]
}
],
"files": [
"!gruntfile.js",
"!README.md",
"!notarize.js",
"!.env",
"!minify.js",
"!src/*",
"!.git/*",
"!resources/*"
]
},
"win": {
"target": "nsis",
"signingHashAlgorithms": [
"sha1"
],
"certificateFile": "",
"certificatePassword": "",
"files": [
"!gruntfile.js",
"!README.md",
"!notarize.js",
"!.env",
"!minify.js",
"!.git/*",
"!resources/mac/*"
]
}
},
"author": "Example",
"license": "ISC",
"devDependencies": {
},
"dependencies": {
}
}

Google Cloud Endpoints REST Discovery Document missing format

I've upgraded to Cloud Endpoints 2.0 which no longer supports RPC. Therefore, I generated a new discovery document and used the service generator with the REST discovery doc as input in order to generate the client library for my iOS app.
Using the new REST discovery doc I am getting the following error when trying to generate the library:
~/workspace/google-api-objectivec-client-for-rest/Source/Tools/ServiceGenerator/build/Release/ServiceGenerator discovery/servUsApi-v1-rest.discovery --outputDir GTLAPI --gtlrFrameworkName GoogleAPIClientForREST
ERROR: Failure, exception: Looking at parameter 'creditKickbackKash:creditAmount', found a type/format pair of 'number/(null)', and don't how to map that to Objective-C
I was able to manually fix this by adding (in numerous places) in the discovery doc, the "format": "double" key and value for all double parameters. Notice creditAmount below is missing a format, like all other doubles.
The generated discovery doc looks like this:
"creditKickbackKash": {
"httpMethod": "PUT",
"id": "servUsApi.admin.creditKickbackKash",
"parameterOrder": [
"userId",
"creditAmount"
],
"parameters": {
"userId": {
"format": "int64",
"location": "path",
"required": true,
"type": "string"
},
"creditAmount": {
"location": "path",
"required": true,
"type": "number"
}
},
"path": "creditKickbackKash/{userId}/{creditAmount}",
"response": {
"$ref": "ResultDTO"
},
"scopes": [
"https://www.googleapis.com/auth/userinfo.email"
]
}
Is anyone else having this issue? How can I get the discovery document generation to properly format the document including double number types?
I had the same problem. I rolled back from 1.9.50 to 1.9.48 and the problem is gone.

Submitting an array of arrays to grape rails

managed to submit a simple array to my grape api following this tip
testing rails grape API with curl, params array
Building a simple workout tracker that generates a graph at the end, through this array of workouts, which should be passed with their keys I guess.
But since what i'm trying to do is a 2D array, i have this output, the type is set to Array[Array], this is the call that i'm currently using
curl --data 'workouts_array[]=1&workouts_array[]=2&workouts_array[]=3' http://localhost:3000/api/v1/workouts/workout.json
And it returns
{
"workouts_array": [
[
"1"
],
[
"2"
],
[
"3"
]
]
}
But i wish to pass something like workouts_array[]=[1][2][3]&workouts_array[]=[4][5][6]
so it returns
{
"workouts_array": [
[
"time": "1", "distance": "2", "calories": "3",
],
[
"time": "4", "distance": "5", "calories": "6",
]
]
}
Thank you for any help, I guess it's just my poor way of using curl
I'm not sure that I correctly understood you but
for your case you can use this query
workouts_array[0]=1&workouts_array[0]=2&workouts_array[0]=3
&workouts_array[1]=4&workouts_array[1]=5&workouts_array[1]=6
it should return smth similar to:
[
[
"1",
"2",
"3"
],
[
"1",
"2",
"3"
]
]
this is array of arrays.
you says you set the type Array[Array] but wanna see the array of hashes. it's kinda different.
BTW, I prefer use JSON payload for those things.

Indexing into JSON

This seems like it should be a very easy question but I'm having some trouble with it. I'm creating my own JSON and I need to index into it in order to seed by database. I've indexed into JSONs before with very little difficulty, but for some reason I can't index into my own. That makes me think that there might be an issue with my JSON itself, but I can't see anything that would cause an issue. I appreciate your assistance!
My JSON:
{
"workouts": [
{
"level": "1",
"exercises": [
{
"name": "box jumps",
"difficulty": "3",
"reps": "10",
"sets": "3",
"requirements": [
"sturdy box at least two feet high"
],
"body-part": "quadriceps",
"description": "Plant both feet should length apart and jump onto the box. Once on the box, stand fully upright.",
"pounds": "1"
},
{
"name": "v-press",
"difficulty": "4",
"reps": "12",
"sets": "3",
"requirements": [
"mat"
],
"body-part": "abdominals",
"description": "Lie flat on the ground, then raise your legs and arms slightly off the matt.",
"pounds": "1"
}
]
},
{
"level": "2",
"exercises": [
{
"name": "assisted pullups",
"difficulty": "1",
"reps": "12",
"sets": "3",
"requirements": [
"Assisted Pullup Machine"
],
"body-part": "biceps",
"description": "Kneel on the machine and adjust the weight to your needs",
"pounds": "50"
},
{
"name": "assisted dips",
"difficulty": "1",
"reps": "12",
"sets": "3",
"requirements": [
"Assisted Dips Machine"
],
"body-part": "triceps",
"description": "Kneel on the machine and adjust the weight to your needs",
"pounds": "50"
}
]
}
]
}
In pry, I do the following:
require "json"
f= File.open("workout.json")
mylist = JSON.parse(f.read)
When I try to index in, I get various errors (syntax error, no method errors, nil). Below are some examples of indexing I have attempted.
mylist.workouts
mylist[:workouts]
mylist[0]
mylist[:workouts][0][:level]
Thanks in advance!
The keys in the Hash after parsing the JSON data are strings not symbols. Try this :
mylist['workouts']
mylist['workouts'][0]['level']
A couple of points to remember :
Strings and Symbols are not interchangeable as keys in a Hash. They both are different objects and hence different keys.
To get the behaviour of the params in Rails controller where strings and symbols are interchangeable you need to instantiate an instance of HashWithInDifferentAccess. It is a separate utility class provided by Rails and is not part of the Ruby stdlib
The gem jbuilder is not a JSON parser. It is a JSON creator. It is used to create JSON structures from Ruby objects, used mostly in writing views for JSON responses. It is analogous to how ERB is used for HTML responses.
JSON has been part of Ruby stdlib for some time now (i.e. JSON parsing and serialization does not require any additional gems).

Resources