API Google DotNet

Rikarddo
Member Posts: 80
Hello,
I am trying to create a Report Only processing, that calculates the distance between two Local Post Codes ( My Company WhareHouse and Client).
I'm using a variable dotnet getdistance from google to calculate the distance. But i have some problems.
I have more than 30k lines to calculate, and not all gives back distance different from 0.
My table structure is like this:
Customer No|PostCodeOrigin|PostCodeDestination|Distance
where
Customer No|PostCodeOrigin|PostCodeDestination is a key.
the code does something like this
MyTable.RESET;
IF MyTable.FINDSET THEN REPEAT
...
Code to get the Post Codes and other data
.....
Distance:=GetDistance(PostCodeOrigin, CountryOrigin,PostCodeDestination,CountryDestination);
IF Distance= 0 THEN
Distance:=1;// so i can know what calculation failed
Mytable.Modify;
COMMIT;
SLEEP(1000);
Until Mytable.Next=0;
How can i complement the variable distance so that if it gets 0 there can be other way to get distance by other fields of Customer and Location tables.
Then how can i pass the limit of requests . I don't know what is the limit but i guess is very little.
Or is other way of getting distance between to points in NAV?
Really need help on this one :-/
I am trying to create a Report Only processing, that calculates the distance between two Local Post Codes ( My Company WhareHouse and Client).
I'm using a variable dotnet getdistance from google to calculate the distance. But i have some problems.
I have more than 30k lines to calculate, and not all gives back distance different from 0.
My table structure is like this:
Customer No|PostCodeOrigin|PostCodeDestination|Distance
where
Customer No|PostCodeOrigin|PostCodeDestination is a key.
the code does something like this
MyTable.RESET;
IF MyTable.FINDSET THEN REPEAT
...
Code to get the Post Codes and other data
.....
Distance:=GetDistance(PostCodeOrigin, CountryOrigin,PostCodeDestination,CountryDestination);
IF Distance= 0 THEN
Distance:=1;// so i can know what calculation failed
Mytable.Modify;
COMMIT;
SLEEP(1000);
Until Mytable.Next=0;
How can i complement the variable distance so that if it gets 0 there can be other way to get distance by other fields of Customer and Location tables.
Then how can i pass the limit of requests . I don't know what is the limit but i guess is very little.
Or is other way of getting distance between to points in NAV?
Really need help on this one :-/
0
Comments
-
1. How is distance calculated/obtained?
2. COMMIT is bad, especially inside loop.
3. Your code is probably a part of some batch process and you should divide it to filling other data and distance setting processes.0 -
My variable:
Name: getDistance
DataType : DotNet
Subtype : GetDistance.GetDistance.'GetDistance, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
Length
Why commit is bad?0 -
COMMIT is bad because if you run the report as a part of some bigger code you will get unexpected commits half way through your process. If this report is standalone and will never be used as a part of some bigger process then it is fine.. However you know what they say - never say never, which imho is true especialy in software/coding domain
Better than COMMIT imho would be to put your call to GetDistance in a TryFunction, so any .NET errors would not rollback transactionREPEAT IF NOT TryGetDistance(..) THEN CalcDistanceUsingAlternativeMethod(...) UNTIL...
There is no generic way of getting a distance in NAV.
You mat come up with some alghoritm (store geo coordinates along post-codes?), or build your own .NET assembly, or use som alternative WEB API (Bing?), or build/get table of distances between postcodes in some external software, preload it into NAV table and keep it as a dictionary. You can also ask a user and how far is between A and B and remember the answer for future use.
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Also I'd be questioning using Customer No in Primary key. Your own code sample
Distance:=GetDistance(PostCodeOrigin, CountryOrigin,PostCodeDestination,CountryDestination);
shows clearly that the distance between point A and B does not depend on Customer No. - so why to store and calculate the same thing over and over for different customers?Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions