w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Checking if Zipcode field has value of 99999... $(this).attr('id') == 'zipcode' && ($this.val(99999)))
The form $something.val('99999') sets the value and always evaluates to true in a conditional statement (the return value is the jQuery object $something). If you want to check/test the value, use something like if($something.val() === '99999'). You can check multiple values in the following way: var zip = $zipcode.val(); if (zip == 0 || zip == 12345 || zip == 99999) { $zipcode.addClass('error'); } else { $zipcode.removeClass('error'); } Note that you probably want to use == for comparisons in this particular case ('00000' == 0 is true and '00000' === 0 is false). For further reading, see Does it matter which equals operator (== vs ===) I use in JavaScript comparisons?.

Categories : Jquery

How can I turn a massive number of coordinates into a boundary or polygon?
Instead of having tomany points, you can put all those coordinates to form lines or polygons. For doing lines see the example from the simplekml Linestring tutorial. You can also learn from the MultiGeometry tutorial. Depending on the resolution that you need, you can also try to decimate your data with python before passing it to kml.

Categories : Python

How to use GeoDjango with Haystack?
I'm using a very similar setup (Django 1.5.4, Haystack 2.0.0, Elasticsearch 0.90.0) and this is what I've got: from haystack.utils.geo import D, Point from haystack.views import SearchView class MySearchView(SearchView): results = super(MySearchView, self).get_results() ... lng = -112.0739 lat = 33.4492 center = Point(lng, lat) radius = D(mi=50) results = results.dwithin('geo_point', center, radius) ... return results An important thing to keep in mind as well is the backend. According to the Haystack backend support matrix (http://django-haystack.readthedocs.org/en/latest/backend_support.html#backend-support-matrix) only Solr and Elasticsearch support spatial data.

Categories : Django

GeoDjango GEOSException error
This is my solution (obviously it is ugly, like my English, but works). The problem is that the versions string has an white space unwanted in the RegEx. The error says: GEOSException: Could not parse version info string "3.4.2-CAPI-1.8.2 r3921" And the geos_version_info warns: Regular expression should be able to parse version strings such as '3.0.0rc4-CAPI-1.3.3', '3.0.0-CAPI-1.4.1' or '3.4.0dev-CAPI-1.8.0' Edit this file: site-packages/django/contrib/gis/geos/libgeos.py Look for the function: geos_version_info And change this line: ver = geos_version().decode() With this line: ver = geos_version().decode().split(' ')[0]

Categories : Python

How get zipCode from CLPlacemark , I get it always is null?
I guess you probably only had a 'bad' coordinate, where no zip code exists. Try the following snippet. It should display various information and the zip code '80802' at the end: CLLocationCoordinate2D myCoordinates = { 48.167222, 11.586111 }; CLLocation *location = [[CLLocation alloc]initWithLatitude:myCoordinates.latitude longitude:myCoordinates.longitude]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"%d Placemarks %@", placemarks.count, placemarks); CLPlacemark *place = [placemarks objectAtIndex:0]; NSLog(@"Placemark %@", place); NSLog(@"Address Dictionary: %@", place.addressDictionary); NSLog(@"Zip key %@", [place.addressDictionary objectForKey:(NSStrin

Categories : Misc

regex not working for ZipCode
Within Javascript, you must escape all escape characters that are not used by the Javascript itself. Replace all backslashes with double backslashes within your regex, or (as noted by OP in that answer), denote a regex using forward slashes as boundary characters instead of listing it as a string that javascript will attempt to interpret. Forward slashes are syntactic sugar for explicitly writing new Regexp("...");.

Categories : Jquery

Display PointFields in GeoDjango interface
My guess is that you switched the latitude and the longitude. Looking at the coordinates you gave, I assume that you wanted the latitude to be 43.620416, and the longitude to be 7.065491, so that the point would be in France. However, according to the doc, GeoDjango expects the first value to be the longitude, and the second one the latitude. Switching these two coordinates may have caused GeoDjqngo to get lost with the values you gave. (4856153.76879, 788079.64711) may then be some internal representation of the point you gave.

Categories : Python

City <-> Zipcode database design
It differs. In Holland we got multiple zipcodes per street, most of the time. The zip codes are so fine grained (consisting of 4 digits + 2 letters), that just the zipcode and the address house number is enough to uniquely identify a building. In Belgium, though, there's a 4 digit postal code, and a couple of towns can have the same zipcode, while it is still possible that a larger city has multiple zipcodes. It can even happen that a city has multiple zipcodes, while each (or some) of them are shared with some smaller towns as well. So I would almost say that there is not relation between zip code and city, or at least no one definition that works on a global scale. If you would store it in a database, then it's definately a m:n relation.

Categories : Database

Shapefile zipcode area merge
You need a planar geometry library. Here are a few: JTS Topology Suite - a Java library GEOS - a C++ version of JTS Shapely - a Python wrapper for GEOS

Categories : Misc

Find Zipcode in range of Zipcodes
Normally i would create a function within the sql-server. Because you don't want to retrieve all rows and compare them local. It should do something like a between but stripping the alphabetics first. The function prevents implementing code more than twice.

Categories : C#

Trying to compare zipcode distances by using the google API
What about that? http://maps.googleapis.com/maps/api/distancematrix/xml?origins=NEW-YORK-10001&destinations=WASHINGTON+20001&sensor=false Result: <DistanceMatrixResponse> <status>OK</status> <origin_address>New York, NY 10001, USA</origin_address> <destination_address>Washington, DC 20001, USA</destination_address> <row> <element> <status>OK</status> <duration> <value>13082</value> <text>3 hours 38 mins</text> </duration> <distance> <value>364365</value> <text>364 km</text> </distance> </element> </row> </DistanceMatrixResponse> Source: How to

Categories : Javascript

How to turn silent mode on during a specific time period in Android? and turn back to normal after the whole duration?
You can use the android FrameWork class AudioManager as follow : AudioManager manager = (AudioManager)getSystemService(AUDIO_SERVICE); manager.setRingerMode(AudioManager.RINGER_MODE_SILENT); Hope it helps :)

Categories : Android

dynamic zipcode option to a weather plugin
There is no below, $.getJSON is async, so you do it in the success handler : $.getJSON('http://freegeoip.net/json/', function(data) { $.simpleWeather({ zipcode: data.zipcode }); });

Categories : Javascript

parameterized sql query for zipcode and radius not working
you are using "order by" clause before "where" that is one of the problem and you can't use alias in where condition is another problem . please try following query : Declare @Longitude Decimal(8,5) Declare @Latitude Decimal(8,5) Select @Longitude = Longitude, @Latitude = Latitude From ZipCodes Where ZipCode = '20013' Declare @Distance int set @Distance = 5 Select persons.personName, ZipCodes.City, dbo.CalculateDistance(@Longitude, @Latitude, ZipCodes.Longitude, ZipCodes.Latitude) As Distance From persons Inner Join ZipCodes On persons.zipcode = ZipCodes.ZipCode WHERE dbo.CalculateDistance(@Longitude, @Latitude, ZipCodes.Longitude, ZipCodes.Latitude) <= @Distance Order By dbo.CalculateDistance(@Longitude, @Latitude, ZipCodes.Longitude, ZipCodes.Latitude)

Categories : C#

Enabling button when zipcode is valid - is not working
I suppose the best way to validate zip code in your case, is using keyup event so user can see is current zip code valid after every edition $("#locationInput").keyup(function(){ if(--validatin here--){ $("#submitButton").removeAttr("disabled"); } else{ $("#submitButton").attr("disabled", "disabled"); } }); http://api.jquery.com/keyup/

Categories : Jquery

Tween Multiple object turn by turn in tweenlite
Usually I'd do it like this: for (var i:int = 0; i < 5; i++) { TweenLite.to(object, duration, {delay: duration * i}); } It will create all the Tweens at once, but they won't really effect your performance since only the active tweens are really noticeable. I did that with over 200 objects and had no lag at all.You might however want to pool the TweenLite object on mobile platforms, but again - you probably won't see the difference up to 800+ objects.

Categories : Actionscript

How to retrieve the highest peak length of y-coordinates and their respective x-coordinates to a separate file using awk?
File a.awk: { if ( ( NR - 1 ) in x && ( NR - 2 ) in x ) { if ( y[NR - 1] > y[NR - 2] && y[NR - 1] > $2 ) { printf "%d %d ", x[NR -1], y[NR - 1] } } x[NR] = $1 y[NR] = $2 } Run: awk -f a.awk input_file

Categories : Shell

ArrayList select coordinates, if there are less clients than coordinates, give each client a coordinate
You need to override equals() in your Coordinate class. @override public void equals(Object o){ if(o==null) return false; if(!(o instanceof Coordinate)){ return false; Coordinate newO = (Coordinate) o; if(this.x == newO.x && this.y == newO.y) return true return false; } This is because ArrayList#contains uses ArrayList#indexOf() which is defined as: public int indexOf(Object o) { if (o == null) { for (int i = 0; i < size; i++) if (elementData[i]==null) return i; } else { for (int i = 0; i < size; i++) if (o.equals(elementData[i])) /// <--- Uses .equals() return i; } return -1; } Note: While you are at it also override

Categories : Java

Using world Coordinates instead of latitude and longitude coordinates in google maps
I found this: var projection = new MercatorProjection(); var worldCoordinate = projection.fromLatLngToPoint(chicago); Maybe there is a reverse way. Source: https://developers.google.com/maps/documentation/javascript/examples/map-coordinates

Categories : Javascript

Why should zipcode values not be placed in Boyce Codd Normal Form?
Assuming you are talking about 2NF, not the minor difference between 3NF and BCNF, (cause zipcodes don't seem to be relevant to BCNF), then: Yes, that, and the fact that it is unnecessarily obtuse, saves only one byte of storage, (zipcodes are five chars and can be stored in 5 bytes, an integer Foreign Key is 4 bytes), and requires an additional join to retrieve the value.

Categories : Database

Finiding distance(miles) bewteen two places using zipcode
I'd do this in two parts: A geocoding script, run once and results stored in persistent cache (eg. database). This way you will avoid hitting rate limits and speed up the final lookup. Script for calculating distance, run when required or cache this too to build a lookup table storing distances between each postcode and all the others. As you only have 100 zips this lookup table would not be very large. Geocoding <?php // Script to geocode each ZIP code. This should only be run once, and the // results stored (perhaps in a DB) for subsequent interogation. // Note that google imposes a rate limit on its services. // Your list of zipcodes $zips = array( '47250', '43033', '44618' // ... etc ... ); // Geocode each zipcode // $geocoded will hold our results, indexed by ZIP co

Categories : PHP

Understanding the Mapping from View Coordinates to Scene Coordinates
Got the answer from a reply to a cross post I made on Qt forums. The mismatch in coordinates arises from the extra pixels that the frame around QGraphicsView introduces. It is solved by setting: view.setFrameShape(QGraphicsView::NoFrame);

Categories : Qt

Calculate all coordinates to x decimal places between two Lat/Long coordinates
You can compute a voronoi diagram from all the lat lon pairs and then look for adjacent cell. Also note that lat lon are angles and not world coordinate or cartesian coordinates. You can download my PHP class voronoi diagram @ phpclasses.org.

Categories : PHP

Convert Excel worksheet coordinates to screen coordinates
Use the Window.RangeFromPoint method. See here for more details. Basically this shows the xy coordinates for shapes. Also you could use Window.PointsToScreenPixelsX and Window.PointsToScreenPixelsY methods.

Categories : Excel

Converting UIImageView Touch Coordinates to UIImage Coordinates
Something like this should get you going. CGPoint imageViewPoint = [touch locationInView:imageView]; float percentX = imageViewPoint.x / imageView.frame.size.width; float percentY = imageViewPoint.y / imageView.frame.size.height; CGPoint imagePoint = CGPointMake(image.size.width * percentX, image.size.height * percentY); Assuming the UIImageView is called imageView the UITouch is called touch and the UIImage is called image.

Categories : IOS

Convert coordinates of a child object to world coordinates
The question of converting local coordinates to world coordinates has been addressed at THREE.js: Calculate world space position of a point on an object . There might also be helping information at how to: get the global/world position of a child object .

Categories : Three Js

3D Camera coordinates to world coordinates (change of basis?)
In fact you have two basis : one relative to the camera, the other is absolute (the world). So you basically want to transform your relative data into absolute data. Location This is the easiest one. You have to translate the (X,Y,Z) position by the vector t(U,V,W). So all your positions in absolute are (Ax, Ay, Az) = (X,Y,Z)+t = (X+U,Y+V,Z+W). Orientation This is a bit more difficult. You have to find the rotation matrix that rotate your camera from (I assume) (0,0,1) to (Ru,Rv,Rw). You should look at Basic Rotation Matrices in order to decompose the 2 rotations that take (0,0,1) to (Ru,Rv,Rw) (one according to X axis, one according to Z axis for example). I advise you to draw the absolute basis and the vector (Ru,Rv,Rw) on a sheet of paper, it is the simplest way to get the right res

Categories : Opencv

Android app: how to turn off listener and turn it back on again?
Instead of inline creating the SeekBar.OnSeekBarChangeListener, create a member variable of type SeekBar.OnSeekBarChangeListener. When you want it to turn it on, you can pass the variable to it. When you want to turn it off, you can pass it the null. private SeekBar sbt; //Not sure where this gets initialized in your code. private SeekBar.OnSeekBarChangeListener mListener = new SeekBar.OnSeekBarChangeListener() { int progressChanged = 0; @Override public void onStopTrackingTouch(SeekBar seekBar) { // Toast.makeText(ProductDetailsInfoActivity.this,"seek bar progress:"+progressChanged, // Toast.LENGTH_SHORT).show(); // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TOD

Categories : Android

How to get world coordinates from screen coordinates in opengl es2.0?
This is called object picking. There are a whole lot of similar questions here on SO: http://stackoverflow.com/search?q=opengl+object+picking

Categories : Android

Geographic coordinates to screen coordinates algorithm
I'm most fluent in iOS so that's what my answers in. I tried to make as many variables as possible so that you could either manually/programmatically override them without changing too much of the other code. - (CGPoint)convertGeoPoint:(CGPoint)point toView:(UIView*)view { CGPoint geoTopLeft = CGPointMake(-0.00939846, -0.00504255); CGPoint geoBottomRight = CGPointMake(0.009398461, -0.01281023); CGFloat geoWidth = geoBottomRight.x - geoTopLeft.x; CGFloat geoHeight = geoBottomRight.y - geoTopLeft.y; // This is the block you would change to suit your needs CGPoint viewTopLeft = CGPointMake(view.frame.origin.x, view.frame.origin.y); CGFloat viewWidth = view.frame.size.width; CGFloat viewHeight = view.frame.size.height; return CGPointMake(viewTopLeft.x + (

Categories : Android

Match heatmap coordinates with jpeg coordinates in R
And, as I am new to R, I actually do not understand what the h and n stand for, so an explanation of what those do would be helpful.. You can get the documentaiton on any function by preceding it with a question mark, like ?kde2d. If you try that command, you'll see the following in the documentation: h - vector of bandwidths for x and y directions. Defaults to normal reference bandwidth (see bandwidth.nrd). A scalar value will be taken to apply to both directions. n - Number of grid points in each direction. Can be scalar or a length-2 integer vector. Regarding the length and width of the heatmap, I'm a little confused as to what you're specific problem is, but you can export your image using the jpeg command, which takes height and width as inputs. So if you know the heig

Categories : R

Convert absolute coordinates to relative coordinates
i think you have to find out at which coordinates your image is placed on the first page. Let us call them x_abs(picture),y_abs(picture). Then you can compute the relative coordinates of the marker by x_rel(marker) = x_abs(marker) - x_abs(picture) y_rel(marker) = y_abs(marker) - y_abs(picture) On the next page you have to find out again where your image is placed, and retain the absolute coordinates of the marker by x_abs(marker) = x_rel(marker) + x_abs(picture) y_abs(marker) = y_abs(marker) + y_abs(picture) Note that x_abs(picture),y_abs(picture) are now referring to the absolute coordinates of the picture in the second page. Hope that helps

Categories : Javascript

Function that converts GPS coordinates to ENU coordinates?
In this publication there is a lot of information on topic. Additionally there is a Matlab code - this is a good place to start from. The relevant part (from "Converting GPS Coordinates (Φλh) to Navigation Coordinates (ENU) by S. P. Drake):

Categories : Java

geodjango admin : An error occurred when transforming the geometry to the SRID of the geometry
Proj4 and Geos Lib was not properly installed ! It's simplier when you just do that : sudo apt-get install binutils libproj-dev gdal-bin As the official doc said before this line : "On Debian/Ubuntu, you are advised to install the following packages which will install, directly or by dependency, the required geospatial libraries:" Then you're sure everything is correctly installed Source : lien

Categories : Django

Rails - Store 'service range' for restaurants, allow users to search for restaurants who service their zipcode
If you were to go solely off of zip_codes you could have a distance table that mapped the distance between two given zip codes. It'd be like a many-to-many table with itself. The ID could be the zip code and you could have a method like. def distance_to(zip_code) # Find row where two zip_codes are defined and the saved distance end But I don't know if this is something you necessarily want to hold in data. For a couple reasons, one being that the area someone lives in for a zip code varies and thus that distance is not consistent. Finally, there are so many things you could use that do this already. You may then want to consider looking into a maps API. Google, Bing, OpenStreetMaps or some other mapping service with a decent api and just put in the coordinates and the distance giv

Categories : Ruby On Rails

binding a ng-repeat child object to another child object (zipcode +city!)
You could solve this problem by many ways let me just show one of those dummy code <input type="text" ng-model="address.City.ZipCode" ng-change="getCityByZip($index)" /> $scope.getCityByZip = function (index) { $http.get("http://localhost/GetCitiesByZipCode?zip="+$scope.addresses[index].City.zipCode ).success(function (data) { $scope.cityList = data; }

Categories : Angularjs

Turn "abc" to "[97, 98 99]"
You can use list comprehension and ord. >>> nums = str([ord(char) for char in "abc"]) >>> nums "[97, 98, 99]"

Categories : Python

How to turn on 3G?
From your description, it sounds as though you want to turn the 3G device's radio on. You can do this in C# or C++ via Windows Mobile Broadband IMbnRadio and IMbnRadioEvents interfaces. I had a quick look on Google for a Windows setting that would tell the OS not to deactivate the device at shutdown, but didn't find anything. EDIT: MbnApi does let you do a lot of things. It consists of many interfaces, and the two that I linked to above are specifically for switching the radio off and on. You don't need the rest. The 3G module can either be software disabled (radio off/on) or hardware disabled (a switch on the computer). The exact implementation of these two things, is up to the individual manufacturer. They don't work exactly the same on machines from different manufacturers. So

Categories : Windows

Turn value into 2value
So, short answer: What you're looking for is a left shift. in C and many other languages, your particular wish would be served by 1 << 8. You could do it in x86 assembler with shl but there's really no sane reason to do so since pretty much any compiler you come across is going to compile the code into the native shift instruction.

Categories : Algorithm

Turn On GPS using NDK
In general, the Android NDK interface is much more limited than the SDK interface. To supplement it, you are able to access Java functions through the JNI interface. There is no extra functionality in the NDK that does not already exist in the Java SDK.

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.