Exemplo n.º 1
0
	try:
		call_type = CallType.objects.get( name__iexact=row[ "CallType" ].strip().upper() )
		#print "FOUND call_type: %s" % call_type
	except:
		print bail()
	
	try:
		call = Call.objects.get( event_num__iexact = row[ "EventNum" ].strip() )
		action = "UPDATE"
	except:
		call = Call()
		action = "INSERT"
		
	call.description = row[ "Description" ]
	call.event_num = row[ "EventNum" ]
	call.report_num = row[ "ReportNum" ]
	call.response = row[ "Response" ]
	call.address = row[ "Address" ]
	call.zip_code = row[ "Zip" ]
	call.call_time = row[ "CallTime" ]
	call.call_type = call_type
	call.calltype_id = call_type.id
	call.beat = beat
	if ( row[ "Lng" ] is not None or row[ "Lng" ] != "" ) and ( row[ "Lat" ] is not None or row[ "Lng" ] != "" ):
		try:
			call.geom = fromstr('POINT(' + row[ "Lng"] + " " + row[ "Lat" ] +')', srid=4326)
		except:
			print "ERROR setting the geometry! for %s" % row[ "EventNum" ]


	call.jurisdiction = juri
Exemplo n.º 2
0
				new_call.calltype = calltype
				new_call.beat = beat
				new_call.jurisdiction = juri
				new_call.event_num = call[ "event_num" ]
				new_call.response = call[ "response" ]
				new_call.description = call[ "description" ]
				if call[ "address" ] != "" and call[ "address" ] is not None:
					call[ "address" ] = call[ "address" ].replace( "&", " & ")
					call[ "address" ] = call[ "address" ].replace( "US65", "US 65" )
					call[ "address" ] = call[ "address" ].replace( "JRF","James River Freeway" )
					#for some reason there is a bunch of addresses that are like "N; Boonville instead of just N Boonville"
					call[ "address" ] = call[ "address" ].replace( ";", "" )
				
				new_call.address = call[ "address" ]
				
				new_call.report_num = call[ "report_num" ]
				call_time = time.strptime(call[ "call_time" ],"%m/%d/%y %I:%M:%S %p")
				new_call.call_time = time.strftime("%Y-%m-%d %H:%M:%S",call_time)
				try:
					place, ( lat, lng ) = g.geocode( call[ "address" ] + " Springfield, MO",exactly_one=True )
				except:
					print "google geocode failed. trying yahoo"
					try:
						place, (lat,lng ) = y.geocode( call[ "address" ] + " Springfield, MO",exactly_one=True)
					except:
						print "yahoo geocode failed! trying geocoder.us"
						try:
							place, (lat,lng ) = us.geocode( call[ "address" ] + " Springfield, MO", exactly_one=True)
						except:
							print "Geocoder.us failed!!"