lunedì 3 dicembre 2018

CORS - Tomcat - Geoserver

To add CORS headers, I simply added to $CATALINA_HOME/conf/web.xml the following lines:

mercoledì 18 luglio 2018

Arcpy - Update SHAPE@M using Field Value

import arcpy
fc = "LD17_CIPPI"
fields = ['ID', 'KM','SHAPE@M']
with arcpy.da.UpdateCursor(fc, fields) as cursor:
 for row in cursor:
  print row[0]
  row[2] = row[1]
  cursor.updateRow(row)
 
#verify
with arcpy.da.SearchCursor(fc, fields) as cursor:
 for row in cursor:
  print row[0], row[1], row[2]

martedì 19 giugno 2018

arcpy: Accessing parameters in a script tool


The illustration below shows a script tool dialog box with three parameters: an input workspace, a clip feature class, and an output workspace. All feature classes in the input workspace are clipped to the clip feature class (using the Clip tool) and written to the output workspace.
Script tool parameters
In the illustration above, once parameter values have been entered on the tool dialog box and the OK button is clicked, the script reads the values of the parameters using GetParameterAsText(), as follows:
# Import arcpy site-package
#
import arcpy
from arcpy import env

# Read the parameter values:
#  1: input workspace
#  2: input clip features
#  3: output workspace
#
inWorkspace   = arcpy.GetParameterAsText(0)
clipFeatures  = arcpy.GetParameterAsText(1)
outWorkspace  = arcpy.GetParameterAsText(2)
env.workspace = inWorkspace

sys.argv and arcpy.GetParameterAsText

There are two methods for reading parameters: sys.argv and the arcpy function GetParameterAsText(). Either approach can be used. The example above could be rewritten to use sys.argv:
# Read the parameter values:
#  1: input workspace
#  2: input clip features
#  3: output workspace
#
inWorkspace   = sys.argv[1]
clipFeatures  = sys.argv[2]
outWorkspace  = sys.argv[3]
env.workspace = inWorkspace
sys.argv has limitations on the number of characters it can accept. GetParameterAsText() has no character limit. For this reason alone, it is recommended that you use GetParameterAsText.
sys.argv[0] returns the script file name.

martedì 5 giugno 2018

Python: Convert string to number/float

# consigliato
import re
a="PL Km 274+169 (Privato)" 
valore = str(re.sub("[^0-9,+]", "",a)).replace('+','.').replace(',','.')
print valore

result:
274.169

import string
a="PL Km 274+169 (Privato)" 
all=string.maketrans('+','.')
nodigs=all.translate(all, string.digits)
print  str(float(a.translate(all, nodigs)))

import re
a="PL Km 274+169 (Privato)" 
a.replace("+",".")
value = float(re.sub("[^0123456789\.]","",a))
print value

# consigliato
import re
def converti(a):
 valore = str(re.sub("[^0-9,+]", "",a)).replace('+','.')
 return float(valore)

import string
a="PL Km 274+169 (Privato)" 
all=string.maketrans('+','.')
nodigs=all.translate(all, string.digits)
print  str(float(a.translate(all, nodigs)))

result:
274.169

venerdì 11 maggio 2018

SQL ORACLE: LEAD

SELECT last_name, hire_date, LEAD(hire_date, 1) OVER (ORDER BY hire_date) AS "NextHired" FROM employees WHERE department_id = 30; LAST_NAME HIRE_DATE NextHired ------------------------- --------- --------- Raphaely 07-DEC-94 18-MAY-95 Khoo 18-MAY-95 24-JUL-97 Tobias 24-JUL-97 24-DEC-97 Baida 24-DEC-97 15-NOV-98 Himuro 15-NOV-98 10-AUG-99 Colmenares 10-AUG-99

martedì 13 marzo 2018

How to convert milliseconds to date string in Oracle SQL

select to_char(to_date('1970-01-01 00','yyyy-mm-dd hh24') + (1517356800000)/1000/60/60/24 , 'YYYY-MM-DD HH24:MI:SS') datestr from dual;

Best dns 2023

  Best Free & Public DNS Servers Provider Primary DNS Secondary DNS Google 8.8.8.8 8.8.4.4 Control D 76.76.2.0 76.76.10.0 Quad9 9.9.9.9 ...