Thursday, April 25, 2019

geohub hub opendata arcgis api


  https://geohub.lacity.org/data.json








---------------------------------------------------------------------------------------
https://community.esri.com/thread/226451-arcgis-open-data-api


I'm looking for a simple way to get the total number of datasets of an instance under *.opendata.arcgis.com.
The only way I found till now is to call data.json and then iterate through all its results/pages, e.g. https://alcaldiadeguarne-guarne.opendata.arcgis.com/data.json where there are 40 datasets.
I was wondering if could call e.g. api/v2/datasets and provide a filter with a parameter URL like this
Can you help me on this?
Thanks.

Hi Andreiwid,

You can return total datasets by a given source by filtering on the source field and looking at the aggregation values at the bottom of the json document. For example, if you call https://opendata.arcgis.com/api/v2/datasets?filter[source]=Municipio%20de%20Guarne and collapse the data field, you should see something like this:





After testing a lot of possibilities, I ended up making a sequence of 3 APIs in order to get the number of datasets of a given installation:

  1. ‘data.json’ – returns a list of the first 1,000 datasets of an installation. This API is necessary to extract at least one dataset ID to be use in next request.
  2. ‘/api/v2/datasets/{:id}’ – returns further details about a dataset where it is possible to access the standardized field ‘Owner’ necessary to make next request.
  3. ‘/api/v2/datasets’ – returns all the datasets to a given ‘Owner’ of an installation as well as the nested attribute ‘meta.stats.totalCount’ in the resulting JSON dictionary which finally specifies the number of existing datasets.

My experiments reported the API sequence 1 returns an empty dataset array for some installations. If you are curious about that, see https://data-brookhavenga.opendata.arcgis.com/data.json and https://data-eastlongmeadow.opendata.arcgis.com/data.json.

Saturday, April 13, 2019

ipfs auto restart


https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ



https://medium.com/@chetcorcos/a-simple-launchd-tutorial-9fecfcf2dbb3


this sh file is locate at :/Users/sirius/ipfs_auto_restart.sh

to run this file once:
     sh /Users/sirius/ipfs_auto_restart.sh

create this file:

   sudo vim /Users/sirius/ipfs_auto_restart.sh

then, copy past below script
then
  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key

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


#!bin/bash
#Start  only if it is not running
SERVICE="ipfs"
if pgrep -x > "$SERVICE" >/dev/null
then
 "$SERVICE is running"
else
 ipfs daemon
 echo "$SERVICE stopped, but re-started...."
fi


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

========  create a plist file =================

sudo vim /Library/LaunchDaemons/com.ipfs.auto.restart.plist

copy below xml and past, then exit

  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key



ProgramArguments              touch         /tmp/helloworld    









    Label
    com.ipfs.daemon
        ProgramArguments

                 
              sh
              /Users/sirius/ipfs_auto_restart.sh
      

    KeepAlive
        StartInterval   
    10











    Label
    com.ipfs.daemon
    Program
    /Users/sirius/ipfs_auto_restart.sh
    KeepAlive
   

    StartInterval   
    10





 ...............................................................................
Before run
                          ipfs add -r xxxx

must close all ipfs daemon from task manager

clean close all process.

 get error:

siriuss-mini:~ sirius$ ipfs add -r /Volumes/original-1/fileRestAPI/Los_Angeles_County_Land_Records
Error: cannot connect to the api. Is the deamon running? To run as a standalone CLI command remove the api file in `$IPFS_PATH/api`


you have to go d:\ipfs_repo
to delete api file and repo.lock file,
because when you force quit ipfs desktop, those 2 file left un-closed,
you must manually delete them.

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

Tuesday, April 9, 2019

VectorTileServer vtpk


(VectorTileServer)


sample


https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services?f=html


https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Esri_Childrens_Map/VectorTileServer?f=jsapi

https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Esri_Childrens_Map/VectorTileServer/tile/{z}/{x}/{y}.pbf


https://gis.stackexchange.com/questions/270827/create-image-from-esri-vectortileserver-using-script







openlayers - sample
https://openlayers.org/en/latest/examples/vector-tile-info.html




esri-doc


https://developers.arcgis.com/rest/services-reference/vector-tile-service.htm



https://www.arcgis.com/home/search.html?t=content&q=tags%3AVTPK&start=1&num=20

Tuesday, April 2, 2019

Launch multiple instances of application in Mac

Open Terminal and type:
open -n -a "APPLICATION NAME"

-n: new instance window
-a: application name


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

How to Launch GUI Applications from the Terminal

Feb 1, 2007 - 30 Comments
terminalWe all know how to launch applications from the GUI with a double-click on the icon or clicking on the app in the Dock, and there are numerous ways to do so, and they’re all relatively speedy. If you spend a decent amount of time with the command line though, it’s nice to be able to launch Mac apps directly from there as well. Also, the Terminal has a fair share of applications that run in text based mode, but maybe you wanted to edit a text file in the OS X GUI app TextWrangler rather than the text based nano or vim.
We’re going to demonstrate how to launch any graphical Mac app from the command line of OS X, including how to open specific files from the command line with a GUI app, and how to edit and open those files with root access if it’s necessary.

Opening Mac OS X Applications from the Command Line

The Terminal command to launch OS X gui apps is appropriately called ‘open’ and here is how it works at it’s most simple:
open -a ApplicationName
That will open the defined app named “ApplicationName”.
But open is much more powerful than that. If you just type ‘open’ at the command prompt, you’ll return the basic help file with details on how to properly use the command with a variety of flags and syntax. While the open command exists in all versions of Mac OS X, the abilities vary somewhat depending on what version of OS X the Mac is running. Nonetheless, in modern releases this is what you’ll see:
$ open
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b ] [-a ] [filenames] [--args arguments]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-F --fresh Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
-R, --reveal Selects in the Finder instead of opening.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
--args All remaining arguments are passed in argv to the application's main() function instead of opened.
-n, --new Open a new instance of the application even if one is already running.
-j, --hide Launches the app hidden.
-g, --background Does not bring the application to the foreground.
-h, --header Searches header file locations for headers matching the given filenames, and opens them.
In other words, example simple command syntax could look like the following, opening “ApplicationName” with the file located at the path ‘/file/to/open’:
open -a ApplicationName /file/to/open
You’ll note you don’t need the full path to the application name, but you would need the full path to a file name.
The usage is likely self explanatory to those who have experience in the command line environment, but for those who are new to the Terminal, don’t be too confused, it is easy to use and we’ll explain. For example, if you want to edit /etc/motd with TextWrangler to change your Message of the Day, but you hate the command line editors nano and vi, here is what you’d type:
$ open -a TextWrangler /etc/motd
Now you can edit these files in the familiar GUI. open is smart enough to know that when you apply the -a flag, you are launching an application so you don’t need to type in its full path. Obviously, it’ll still need the full path to the file you’re editing though.
There are many other usages for the open command rather than just editing text files, so use your imagination and get creative. open could be particularly useful to system administrators who utilize it in a shell script, perhaps to launch a specific GUI application at a scheduled time.
Also worth noting is that if you are launching an application with spaces in its name, you’ll want to add a backslash after each word, opening Adobe Photoshop CS would look like this:
$ open -a Adobe\ Photoshop\ CS

Launching GUI Apps as root from the Command Line

You can even open files with sudo by using the open command if you need to edit a file as root, for example:
sudo open -a TextEdit /tmp/magicfile
This will launch the target file into the desired application as root user, giving full root privileges to edit and modify the file, which is quite helpful for editing many system files. Of course, don’t modify any system file if you don’t know what you’re doing.

Creating Shell Aliases for Frequently Launched GUI Apps

So it’s kind of a pain in the butt to type a full command repeatedly, or to type out all that out over and over again, right? Well let’s make it easier by assigning an alias to an application that gets frequently launched. We’ll take the aforementioned Adobe Photoshop app as an example since the file name is lengthy, so here’s how we’ll do this with the Mac OS X default Bash shell:
First launch the profile or .bash_profile into a text editor:
$ nano .profile
or
$ open -e .profile
Ignoring whatever else may be in this file (it could be empty also), add the following to a new line:
alias photoshop="open -a Adobe\ Photoshop\ CS"
This creates an alias, so that the “open -a Adobe\ Photoshop CS” command is now shortened to simply ‘photoshop’. Save .profile, and you’re on your way! You can use the alias command in conjunction with open for virtually anything, just be sure to pick an alias to a command that doesn’t already exist.
The open command is really handy as you can see, if you have any other great uses for it in OS X, be sure to let us know in the comments.