Tuesday, April 10, 2018

Paiza


Error :   grunt serve

https://github.com/angular-fullstack/generator-angular-fullstack/issues/2690

issue resolved after going back to node 5.6.0

----------------------------------------------------------

nvm install windows 10 problem

https://github.com/coreybutler/nvm-windows/issues/150




=======================================================
Error :  npm install

https://github.com/node-inspector/v8-debug/issues/26

solution:
-----------------
Delete "grunt-node-inspector" from package.json
Heroku does not like grunt-node-inspector with node v7.1.0

Tuesday, April 3, 2018

arcgis json to geojson

https://gis.stackexchange.com/questions/13029/converting-arcgis-server-json-to-geojson




https://github.com/Esri/terraformer-arcgis-parser/issues/44

=====================================================



arcgis server rest api, feature service,
if you query the layer, with URL like this, .../FeatureServer/query?layerDefs=...
http://services3.arcgis.com/your_token/arcgis/rest/services/Parcels/FeatureServer/query?layerDefs={"0":""}&returnGeometry=true&f=pgeojson&geometryType=esriGeometryEnvelope&geometry={"xmin" : -117.923158, "ymin" : 33.644081, "xmax" : -117.921436, "ymax" : 33.645157,"spatialReference" : {"wkid" : 4326}}
You can not set geojson format, f=pgeojson will be bad request, f=json, because the return stuff is not feature, the layers json was return.
Try this html query page, you can see, no geojson option,
 http://services3.arcgis.com/you_token/arcgis/rest/services/Parcels/FeatureServer/query
If you want to return geojson (feature), you must use this URL .../FeatureServer/0/query...
/0/ means layerID, if on has only 1 layer, then layerID = 0.....
Try this html query page, you can see, geojson is option, because you are query specific layer with layerID = 0
http://services3.arcgis.com/your_token/arcgis/rest/services/Parcels/FeatureServer/0/query
Note: remember to set those 2 parameters: outSR=4326&f=geojson in the URL spatial reference ID, srid = 4326, because web map all use this, f means format, both f=pgeojson and f=geojson works. If you don't set outSR=4326, arcgis server rest api by default will NOT use 4326, instead use something else, only 4326 has unit degree, which is used in most web map. Other format would not work with web maps.
By the way, for those want to use arcgis server rest api with tile service,
tilestream and others
/zoom(z)/x/y.png
http://localhost/v2/city_parcels/12/706/1641.png
arcgis server tile service: no png, x and y in different order
     /zoom(z)/y/x

==========================================================

ArcGIS now supports GeoJSON

Now ArcGIS Online has GeoJSON through ArcGIS Rest API URL. All you need to do is set f=geojson in the URL and configure the service. Be aware, by default, ArcGIS online will not allow GeoJSON export until you explicit permit other output formats.
Here is how to enable the export:
  1. Log into arcgis online
  2. click the feature layers,
  3. click the setting tab
  4. check this box that says
    Export Data
    Allow others to export to different formats.
  5. Save and wait a few minutes.
In the query page, you should see the output format dropdown list with the GeoJSON option. The old was called json.
===============================================

Converting ArcGIS JSON to GeoJSONThere in pure Browser
there are 2 ways you can do
Note: use in node.js and use in browser are different, details see link
use in browser, ArcgisToGeojsonUtils is global var reference the entry point of this module
<script src="https://unpkg.com/@esri/arcgis-to-geojson-utils@1.2.0/dist/arcgis-to-geojson.js"></script>

// parse ArcGIS JSON, convert it to GeoJSON
const geojson = ArcgisToGeojsonUtils.arcgisToGeoJSON({
"x":-122.6764,
"y":45.5165,
"spatialReference": {
  "wkid": 4326
}
});
To use this esri lib in browser, you should use some bundler, please follow:
a) You need to compile all the module source file into a single bundle.js
rollup.js install by
npm install --global rollup
then go to your js lib root folder, find the entry point js file, in this case it is index.js
$ rollup index.js --format umd --name "esri_arcgis_to_geojson" --file bundle.js
You should find a new file bundle.js in your root directory.
Now in your browser html file, include this bundle.js file
<script src='.../.../.../bundle.js'>
You can use it now by
  // parse ArcGIS JSON, convert it to GeoJSON
  var geojson = esri_arcgis_to_geojson.arcgisToGeoJSON({
                            "x":-122.6764,
                            "y":45.5165,
                            "spatialReference": {
                              "wkid": 4326
                            }
                            });

 // take GeoJSON and convert it to ArcGIS JSON
  var arcgis = esri_arcgis_to_geojson.geojsonToArcGIS({
                            "type": "Point",
                              "coordinates": [45.5165, -122.6764]
                            });enter code here
Remember esri_arcgis_to_geojson is the name you named the lib
This becomes the global variable name, available in browser.
The trick is, bundle process add instant implement function like (function xx {}) here is the top part from bundle.js
  (function (global, factory) {
     typeof exports === 'object' && typeof module !== 'undefined' ? 
        factory(exports) :
      typeof define === 'function' && define.amd ? define(['exports'], 
         factory) :
      (factory((global.arcgis_to_geojson = {})));
      }(this, (function (exports) { 'use strict';

         ***ORIGINAL SOURCE CODE OF JS MODULE***

     })));


========================================================================



**Converting ArcGIS JSON to GeoJSONThere in pure Browser**

there are 2 ways you can do

**1) [TERRAFORMER][1]**

   Note: use in node.js and use in browser are **different**, details see link


**2) [Esri/arcgis-to-geojson-utils
][2]**

Esri does not provide the bundle.js, so you can **NOT** use this lib in browser directly

As of today, you can not load module in browser.

You can only use ESIR lib in node.js, not browser.




**To use this esri lib in browser, you should use some bundler,** please follow:

a) You need to compile all the module source file into a single bundle.js

   [rollup.js][3] install by

    npm install --global rollup

then go to your js lib root folder, find the entry point js file, in this case it is **index.js**

    $ rollup index.js --format umd --name "esri_arcgis_to_geojson" --file bundle.js

You should find a new file bundle.js in your root directory.

Now in your browser html file, include this bundle.js file



*************************************************

Featureset JSON


ArcGIS REST API specification defines featureset as a collection of features with a specific geometry type, fields, and a spatial reference. The JSON format of featureset is shown below. The geometryTypespatialReference, and Fieldsproperties define the geometry type, spatial reference, and field definitions for the collection of features. The featuresproperty defines the collection of features. Each feature in the collection has a geometry and field values (known as attributes) . The hasZ and hasM property specifies whether the features geometry have Z and M values.
JSON representation of Featureset
{ 
"displayFieldName" : "",
"fieldAliases" : {
  "" : "",
  "" : ""
},
"geometryType" : "",
"hasZ" : <true|false>,  //Added at 10.1
"hasM" : <true|false>,   //Added at 10.1
"spatialReference" : <spatialReference>,
"fields": [
            {
                "name": "",
                "type": "",
                "alias": ""
            },
            {
                "name": "",
                "type": "",
                "alias": ""
            }
        ],
 "features": [
            {
                "geometry": {
                    <geometry1>
                },
                "attributes": {
                    "": <value11>,
                    "": <value12> 
                } 
            },
            {
                "geometry": {
                    <geometry2>
                },
                "attributes": {
                    "": <value21>,
                    "": <value22> 
                } 
            }
        ]
}