Vies database split address - api

I'm using vatlayer API for getting company information by put in the vat number. https://vatlayer.com/documentation
Now I want split address info in the state, zipcode, addressline and address number.
I get the address info: BREDABAAN 13052900 SCHOTEN.
The address number and zipcode stands against each other without spacing. (1305number and 2900 zipcode).
Is there another API for working with the vies database where i can split these information? Or an work around for this bug?
VatLayer don't support the split atm.
I get the address information by:
$("#organisation_address_line_1").val(json.company_address);
Thanks in advance,

There's quite a lot of API's to handle VAT validation but the ones that provide information about the trader essentially all rely on the official API at http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl . It connects directly to the VIES system. Perhaps the values returned there are a bit different: it's worth trying your validation that way as well.
Unfortunately, since VIES does not return structured addresses (except for approximate matches, but only Spain supports them at the moment) and does not specify a common format for the free text addresses, you're going to have to deal with whatever format the country has chosen to provide, which means manual parsing.
I reckon 3rd party wrapping API's could handle guessing the format and splitting the formats on their own but I am not aware of any that would do it.

Related

How can I determine the IANA timezone of a specific location

Is there a (free) webservice where I can a) give it an address (either full or city, state/province and zip), and b) get the IANA timezone of that address?
Use case: I have a form where a user manages clinics. Each clinic has an address. I want to preselect that IANA timezone of that address, so that I can adjust appointment date/times associated with that clinic.
I know that the Google Maps API and Bing Maps API can give me the lat/long of an address, and that there are other services that can give me the IANA TZ based on the lat/long. That said, those api's require subscriptions and keys and contracts, and it would also require a two request approach to get the single piece of data.
Address geolocation is a hard problem. It requires deep understanding of address systems and reacting to ever-changing, real-world, messy scenarios.
For example, you could get a database of the Zip codes of the United States and their approximate locations, but it would only be a snapshot. You'd find over time that new Zip codes would be added and missing from your data, and that existing Zip codes had been expanded to include other areas. You'd also find many Zip codes that are "non-locatable", such as those used to send mail to military overseas. You could even find a single Zip code that has addresses in two different time zones.
Take international concerns into effect and you'll find all sorts of edge cases. Every country and territory has their own special rules and situations.
It is a problem worth paying a service provider for. Trying to do geolocation in an offline manner might be possible, but it isn't advised.
The second part - figuring out which time zone goes to a location, is also messy. However it's slightly easier to coordinate. The Time Zone Boundary Builder is the main open-source project that attempts this. Most libraries referenced here use that data. But even then, it has updates and relies on borders established by Open Street Map data. Some of those borders are in dispute, so a service from Google, Microsoft, or others could give different results because they have map data with different borders. If you care about such things then you might want to test some edge cases against the different providers to see if you're satisfied with the results. You may find that the TZBB data works well, or you might prefer one of the online solutions.

How can I save or get data about places near me without breaking policies

This is more of a general programming question.
I'm trying to create an app, think of it as a Yelp clone. I have most of it working but I'm missing one important feature. The data of the places around me. For now I'm only focused on food, so I'd like it if I search something like "Pizza", it'd show me all the pizza joints near me.
I was originally planning to use Google Places API. However if you havent heard, they're changing their pricing and lowering the free tier and upping the cost by a huge margin.
There's also the problem of saving the data. One workaround I saw a user suggest was to just keep using Google's API, but every time you make the query, store the data in your own DB as well (I only need address and name and latitude and longitude) so eventually, you'd have what you need in a sense. However I also want to have something like a simple rating system for each place like Yelp, but Google (and all other places like MapBox, Here Maps, etc) states something along the lines of "info from their API should not be stored or cached for more than 24hrs" but it's very broad and not specific.
So what I was planning to do was, call the Google API, grab the 3 info I need (Address, Name, Lat/Lng), add more fields to store the rating, likes, whatever else the user will add. Then store it in my database, but that doesn't seem like a solution now.
So does anyone have any ideas or advice? Or know of a service where I can get the details of all the food places? And if possible, can anyone confirm that storing the Name, Address, Lat&Lng is a violation of their policy since in my eyes, it's public data, but something like the rating that Google provides, or the pictures that Google provides, now that's Google property.
For obtaining places you can use OpenStreetMap, e.g. using Overpass API. Since larger traffic can be expected you should run your own database(s) instead of using the public APIs.
However OSM doesn't contain ratings. So you have to combine this data with some other publicly available rating system.

Moqui / PopCommerce: country-specific postal address format profiles?

I'm totally new to Moqui/PopCommerce and my first impressions of it are great.
One thing that I didn't find how to do was country-specific postal address formatting: unfortunately, every country has a different address format, with different fields, ordering and arrangement of the fields.
For example, in most of Europe, the Zip code is expected left of the city name and there is no '#' sign in front of the house number. In France, the house number is left of the street and followed by a comma.
Some countries e.g. in Asia even have multiple address formats depending on other factors (e.g. rural vs city)
You can see explanations and examples here:
https://en.wikipedia.org/wiki/Address_(geography)#Format_by_country
http://www.columbia.edu/~fdc/postal/
So for any software that handles postal addresses, there are at least two situations where that country-specific address formatting is relevant:
1. in any output of a postal address (e.g. display, printout, mail, pdf, etc.)
2. in input of a postal address (e.g. address input form)
While an input form that doesn't adapt to the country-specific format is only a secondary problem (at least as long as it is only used by internal users and not external customers), any address output (especially one that is seen by any external customers) really HAS to conform to the country-specific address format and order, which means that there should be some way in the input form to choose an address format profile (e.g. by adapting to the chosen country).
I didn't see how to do that easily. I did find a PostalAddressSimpleTemplate variable in /vapps/system/Localization , but as I understand it, adding translations there would make the output dependent on the locale chosen by the user and not on the country of the address.
So my questions are:
* Is there any easy way to do this? (maybe I just didn't find it?)
* If not, is this something that would likely be added in the near future?
To date the functionality in SimpleScreens (which is where the postal address entry forms and display templates are located) is more USA oriented because all of the sponsorship for it has been by companies in the USA. There have been a few contributions that are localization related, and a few localization components that others have built (see the Add Ons page on moqui.org), but these particular forms seem to be customized rather than made more dynamic to work better across a wider variety of locales.
If you are targeting a specific locale the best thing to do is plugin your own address entry form and display template, and if you are building a public facing web site you probably shouldn't use the forms or templates from SimpleScreens anyway (all are meant for internal applications, or portal sorts of sites for external users with a limited scope, but really not for ecommerce and other sorts of sites where they are publicly available and users won't use them enough to be able to use them with no training or documentation, or from another point of view benefit from the standard UI patterns).
The OOTB input form has started to move in a more country-generic direction with the country drop-down being to the left of the state/province drop-down (for whatever sub-country region is used in the country) and the state/province drop-down reloads from the server when the country is changed.
The output structure (in the address .gstring file, for HTML output) doesn't currently do anything different based on the country.
These will both change over time, but right now basically to handle country-specific input forms or output templates customization is required.

get 9 digit zip code from 5 digit zip code, programmatic, api

I have 5 digit zip codes, these are retrieved from Google Maps Api.
My dilemma is that I have to connect to a remote database which also contains addresses. If the address does not exist in that database, I have to write it, if it does exist then I do nothing except store the ID that database has assigned to the address. The problem arises since the api to check this database does not take wildcards, the addresses in that database have 9 digit zip codes (5+4) and will not return that the rest of the address matches my address with 5 digit zip codes.
The remote system will tell me that the address does not exist with the ones I send it.
So to prevent duplicate addresses from being written to the database I would need to find the 9 digit version of the zip code I have before sending it.
How would this be done? Is there a formula for determining what the last 4 digits of a 5 digit address are? Does the USPS have an API? Does the Census have a giant table?
Insight appreciated
You are only allowed to use the USPS API for information if you are using the USPS to send out mail...
But you could check out SmartyStreets (I used to work there) or another CASS-Certified vendor. They are licensed for address verification, and you can also perform city-state and ZIP code lookups without an address (depending on who you choose).
I think you'll find them much easier and more comprehensive than the default USPS web service.
Here's some sample code... take your pick: https://github.com/smartystreets/LiveAddressSamples
The US Postal Service have a number of APIs. Their "Address Information APIs" include:
Address Standardization
Eliminate addressing errors and help ensure accurate and timely delivery. This tool corrects errors in street addresses, including abbreviations and missing information. It also supplies a ZIP+4® Code.
ZIP Code™ Lookup
Find matching ZIP Codes or ZIP+4 Codes for any given address, city, and state in the U.S.
City/State Lookup
Use a ZIP Code to get accurate city and state information.
The Address Information APIs require permission to use.

How to validate a location address in form?

I want to validate that the postal address filled in by a user is correct.
Assuming that we have the fields street, street_number, postal_code, city and country
How can show errors when the user, types in that his country is France and is city is New York?
or
How can I detect that a postal code doesn't correspond to the city?
Is there a strategy to address this issue with Ruby On Rails or shall I just trust the user entries ?
There are several companies that publish US ZIP code directories, typically not terribly expensive, and some even come with lat/lon data. This is the most common way of validating city and state in the US or North America. Worldwide postal codes to country and city is likely to be a harder problem, or at least a more expensive one.
Another approach would be to use the Google Maps API, perhaps in conjunction with the data you can get from location-aware browsers (all modern ones). To be honest, it's been a while since I have used the API, but seem to recall you can get pretty detailed information given a lat/lon. Google now charges for high use of the Maps API, but if your site has even moderate traffic, you're probably still in the free zone.
At some level, you'll have to trust users. I remember a while back we found anomalies in user reported zipcodes in our database -- seemed like everyone lived in Beverly Hills, CA. This was around 2000, when the original version of the TV show "90210" was still around -- that's the zipcode :-).
Have you considered just a jQuery plugin to verify addresses for you? It's free for many users, up to 250 lookups/mo, and is always current (no need for you to maintain a database).
Incidentally, I work at SmartyStreets. There's also a ZIP code API to look up if cities match ZIP codes and vice-versa. Either way, we've put a lot of effort into making the user experience positive, even when the address they type isn't totally valid.