Gints - 2011-05-19

es: I do not know what kind of automatics was in czaddress
23:38
so I can only gues about what you are willing to achieve with new project :)

one thing from home number is...
23:39
that you can use first number as reference always

like xx/yy

could count for xx

for sorting
23:40
I think to make some automatics we have make number field sorted then

mean ... not as one field

Radomír: Well, surely. I know. That's the reason why I wrote a lenghty response. I wanted to explain my confusion about your proposal.
23:41
Concerning your number: That is exactly the point I was trying to make.
23:42
It's quite hard to put all in a single field.

es: when I build database model... I try to show up reality
23:43
so in reality there is first number

number after slash

number after dash

and letter

not sure there is letter before somewhere
23:44
does number color makes sendse in kind of numbering?

*sense
23:45
like on one street could be red 4 and black 4

Radomír: This depends on the country. In Czech Rep. colors differ city from city.

es: but does it mean somthing in kind of numbering?
23:46
does it gives power to number?

Radomír: Yes, it does.

es: ups

so may be number should be mor generic

Radomír: Why do you ask? Should I explain?
23:47
What number?

es: if it does... then we have to enter also color with number

where it counts

Radomír: Now I understand:
23:48
The colors in CZ only specify the type of the housenumber.

E.g. red means Conscriptionnumber.
23:49
Black is standard house number attached to the street.

es: I do not understund conscription realy
23:50
what is that? :)

Radomír: Ok. Shortly:
23:51
Housenumber 1 starts at the beginning of a street. The next street restarts the numbering. Hence housenumbers are unique inside one street.

Conscription numbers are unique inside one suburb.
23:52
es: k I see

Radomír: Or if the town has no suburbs, then it's unique inside the town.

es: you use them for some cheking?
23:53
in czaddress

Radomír: Yes, indeed.

es: we do not have such numbers

Radomír: I know, they are middle European only.
23:54
es: so we cannot count on them at AddressManager

Radomír: But you have other specialties.

es: they could be used as secondary

Radomír: Oh no!

es: ?

Radomír: The opposite is correct.

es: mean?
23:55
Radomír: Having Conscription number is a great advantage for the programmer.
23:56
es: but in Latvia as example this advantage mean nothing

Radomír: You see a node in the map with cons. num 13. To find corresponding database element.....
23:57
.....you only check this number. No unreliable, typo-prone street name comparison.

I understand your point.
23:58
That is the reason, why I propose to make greater abstraction in the data model.

...starting with the written document.

es: hmm.. but if you just add cons num to building record...
23:59
Radomír: ...in SF.net wiki.

es: you can do whatever you want

Radomír: What do you mean by "cons"?

es: conscription :)

Radomír: Thats not enough.
00:00
es: what else?

mean what you miss?

Radomír: Conscription numbers change the behaviour of the plugin.
00:01
es: mmm yes..

but that's not model

i spoke about db model

Radomír: Without a proper abstraction, you have to write every algorithm specifically for each country.

I see the point
00:02
es: I see yours too :)

Radomír: Let me think a while.
00:03
My argument goes like this:

In your model, post codes are definef for a street, aren't they?
00:04
es: yes

mmm

moment

Radomír: In Czech Republic, houses on one street can have different post codes.

es: same here
00:05
Radomír: Then how do we reflect this in the DB model?

es: so.. my model goes like this ;)
00:06
primary key is for Street Postalcode combination

Radomír: That's a discrepancy, isnt't it?
00:07
es: probably

Radomír: But what code do you write for getting the postcode for a house? House.getPostCode or House.getParent.getPostCode?
00:09
If you say "use if and check for null", I vote a strong "no". :-)

es: Second

House has parent Street
00:10
mean

House has parent Street + Postal code combination

if I understund your question right
00:11
Radomír: Yes, but what if two houses on one street have different post codes?

es: they belongs to "different" streets

Radomír: No! Not in the case of Czech Republic.
00:12
es: name is called same

:)

like if Street is - Brivibas
00:13
and house 40 has index LV01

and house 41 has index LV02

then One street is Brivibas LV01

other street is Brivibas LV02

name of course is same
00:14
but in level of db records they differ

imho there is posibliities:
00:15
* attach postal code to each home

Radomír: Sorry for being frank, but that is what I call a typical example of a "dirty uglyness". Did you call for "modelling reality" at the beginning of our chat.

es: * make postal code area as one more area

give your purposal

Radomír: Ok, let me describe what I have in mind.

It's rather incomplete at the moment, but it will be sufficient for our discussion.
00:24
I propose to split the "DB model" into the "Object model" and "its serialization".

The Object model is the definition of Java classes: House, Street, ViToCi, ElementWithAddress, ...

The serialization is the XML file you write.
00:25
I propose to make the XML file model reality as closely as possible.

The Object model in the other hand is used for the programmer and may be rather complex to capture all anomalities of different countries.
00:26
The central role in the "Object model" will have the House class.
00:27
In order to capture the specific properties of countries, it will be defined as an interface, rather than as a class.

You know the difference, do you?

es: yes

Radomír: Good.
00:28
Now the Czech Parser will define a "CzechHouse" as follows:

class CzechHouse implements House {
private String postCode;

public getPostCode() { return postCode; }
}

Meanwhile the Latvian parser may use the street's post-code to save memory.
00:29
class LatvianHouse implements House {
public getPostCode() {
return getParentStreet().getPostCode();
}

}

You may have different country-specific parsers and different country-specifics XML files.
00:30
So in Czech Republic, we can still rely on the database given us by the ministry of internal affairs without the hassle of updating it manually.

In Latvia, you can use whichever format you like.
00:31
The problem I am thinking about currently is the house-number abstraction.

es: there could be different formats for one country too

Radomír: Different formats of the XML file?

es: yes

Radomír: I agree. Indeed.
00:32
es: depending on source

Radomír: Yes, exactly.

Having separate parsers solves this problem quite elegantly IMHO.

es: yes

Radomír: The problem with abstracting the house numbers is as follows:
00:33
es: but I think making House class implementation for each country is too much

because we have same like Lithuanians
00:34
Radomír: Surely.

Agreed.

es: and chech close to slovaks

Radomír: You can make partial implementations with "abstract classes" and share the models between countries.

es: ok.. problem with abstracting...?
00:35
Radomír: Yes, let me describe it:

In CZ, there is the "housenumber" associated with the street and the "conscriptionnumber" associated with the Village or Suburb.

But there are more problems:

In Russia (and maybe in Latvia as well), you have "corner houses":

They are built on intersection of two streets and they have two numbers.
00:36
One number is associated with one street and the second number is associated with the second street.

es: not in Latvia :)

Radomír: Ok :-)

This is very tricky!

You cannot use House.getParentStreet().

There are two of them!
00:37
Hence I am thinking about defining the interface House as follows:

interface House {
public Set<HouseNumber> getAllHouseNumbers();
}

where the HouseNumber is defined as follows:
00:38
class HouseNumber {
public int getNumber();
public AddressElement getParentElement();

}

Where the AddressElement is the super-class of all Streets, Towns, Cities, Houses, etc.
00:39
There are still some things I need to think about:

1) Some houses do not have a number only, but their number is "12B".
00:40
2) How to serialize the the set of house numbers into a single string?

es: so number class should have more fields

Radomír: Yes, that's one solution.
00:42
es: class HouseNumber {
public int getFirstNumber();
public int getSlashNumber();
public int getLetter();
public AddressElement getParentElement();
}

Radomír: To elaborate on 2): In CZ, we usually write "conscriptionnumber/housenumber" into all official documents.

Ok, back to your example.

That's a good example up to one point:
00:43
How do you define the semantics of "FirstNumber" and "SlashNumber"?

es: Null if no slash number

Radomír: Is it used for the Russian "corner houses"?

es: nop

it is like if you have house 13
00:44
and then build in that place like 3 new houses

they got numbers 13/1 13/2 13/3

Radomír: Ok, I see.

Good idea. I like it.
00:45
What I propose is to write all the details into a document.

Because there are subtleties such as:
00:46
getLetter() must return a "String", not a "char".

In Latin America, houses are named as "35Bis".

es: sure

yes
00:47
and there should be sorting mechanism defined in HouseNumber class'

kind of

mean what which number means in sorting
00:48
Radomír: Yes, that another major issue to think about.

We can simply say that:

interface House extends Comparable<House>
00:49
And let the implementating Parser define the "public int compare(House house);" by its will.

Sorry, back to your question.,

I have misunderstood it!
00:50
You ask how to sort the Numbers of a single House.

es: no no

you understud right

Radomír: Ok, good.

es: I ask about how to put house numbers in order :)

against street :)
00:51
so we get like 13, 13/1, 13/2, 13/3

and order "coeficient" is like
00:52
13 13,1 13,2 13,3

Radomír: Yes, then what do you think about the "interface House extends Comparable<House>" idea?

es: public int compare(House house)

there is only one house

ahh i'ts diff with self
00:53
Radomír: Yes.

es: it will require lot of resources no?

Radomír: Why do you think so?
00:54
It is the standard way of sorting items in Java.

es: if you say so :)

Radomír: Yes, believe me. :-)

The performance is not the issue..

es: so you have big array of Houses....

how you compare?
00:55
mean.. how you make them in line :)

Radomír: Do you know how sorting algorithms work?

es: some

by tossing :)

Radomír: :-)

http://en.wikipedia.org/wiki/Sorting_algorithm
00:56
Do not worry.

I am quite confident about this.

es: so let's do that way

Radomír: But there are more issues:
00:57
[wikipedia:]

In areas of rural Wisconsin [...] for instance, an address on a north-south road 45 blocks north from the baseline is written as 'N4500', while an address 45 blocks west from the baseline on a east-west road is shown as 'W4500'.

We need a prefix to the number.
00:58
Some counties and suburban communities (such as Waukesha and the Town and City of Cedarburg) use a two-part address for both directions for easier referencing within a map and the numbering system (N4500-W4500 for instance).

es: that's what I say about reality
00:59
if it is so... we implement

but it is just question about one more field in HouseNumber class ...

Radomír: But that's what I say about algorithms
01:00
the closer to reality the "Object model" is, the more country-specific algorithms you have to write.

;-)

Yes, in this case, one more field should be enough.

es: yes.. sure :)

what you spoke about one string?
01:01
2) How to serialize the the set of house numbers into a single string?

Radomír: Yes.

es: why you need it?

Radomír: Because the Set<HouseNumber> does not define any ordering of its elements.
01:02
Hence we need something to define that you write "[conscription number]/[house number]" in the Czech republic.

And some other way round in the case of Russia.

es: mmm kind of print()

:)

Radomír: Yes.

I do not have any better ides.
01:03
ideas.
01:04
In some cities, especially hosting large scientific or military research centers in Soviet time, the numbering might be different: houses may have numbers related to the block rather than the street, thus 12-й квартал, дом 3 (Block 12, House 3),[5] similar to the Japanese and Korean systems (see below). Aktau is one example of this.

This is another problem with "Russian" system.

es: about russian devided house.. so you have check each "street" of house to get what you need :)
01:05
Radomír: Yes, exactly.

But there is one more aspect:

es: no problem with block

Radomír: You have to know, how to fill the "addr:street" tag.
01:06
es: this is just another number

Radomír: Yes, you're probably right.

We could use the "getSlashNumber()".

es: yes...

that I was supposed to write
01:07
Radomír: And the "print" method would return "Block 12, House 3".

es: yep

Radomír: In Russian of course. :-)

But back to the "corner" houses.

The order of the numbers also defines which street should appear in the "addr:street" tag.
01:08
Hence if the house is addressed as "Нахимова, 14/41", the "14" appearing first forces the main street to be "Нахимова" and not the intersecting one.
01:09
es: hmm ... which street is intersecting?

I see only one streeet here

Radomír: Well, wikipedia does not give the name of the intersecting road. :-)
01:10
But the DB model does.

es: hmm if I think more....

than... address point... and house... is not one peace
01:11
Radomír: Hmm, yes, that's true.

es: for that we have Set in House :)

ok

set of addresses actualy

Radomír: Well, set of "house numbers" to be exact.
01:12
The whole set defines the "address", which we write on an envelope.

es: address I mean as letter endpoint...

if not count room

Radomír: Yes, right!
01:13
Wikipedia quote: "In Haarlem, Netherlands, red numbers are used for upstairs apartments."

So one house has two addresses.
01:14
es: if you put addreses not on building... but as dots

then you do not have problem of russian houses
01:15
Radomír: Could you elaborate on your idea a bit?

Where do you put the "dots"?

es: there is different aproaches

on entrance, on mid of house

whatever you want inside house :)
01:16
Radomír: Hmm, I am afraid I still do not get it.

You propose to use more "nodes" in the map to represent a single address?

es: no

I purpose for russian two address house
01:17
draw one buliding

and put two nodes... each for each address

Radomír: Well this does not work. I have already thought about it.

es: and each node has own addr:street tag
01:18
Radomír: Imagine that the street "Pushkinova, 14/41" intersects with "Gogolova"

There is no such address as "Gogolova 41/14". It does not exist and the letter sent to such address will not be delivered.
01:19
Hence the second "node" in the map is invalid.

es: realy?

are you sure?

Radomír: Yes, as far I was was once told in the mailing list.

es: mean you can send post only to one of thease addresees ??
01:20
Radomír: I am not Russian, I merely quote what I was told.

es: mmm ... that's kind of russian thinking :)

Radomír: ;-)

Yes, indeed!
01:21
es: so..

where that second address is used?

just to draw on house?

Radomír: Who knows...

es: :)
01:22
does set have first element?

Radomír: Well, it does not.

A list does.
01:23
es: let's use list?

Radomír: But what if there was a country, where both streets had to be written in the "addr:street" tag?

es: and first is main

Radomír: I am not sure about such idea.
01:24
I am thinking about a different approach:
01:25
Let's define 'public Map<String,String> getMapFields();", which defines how the House should be serialized into the map.

It returns key-value pairs of all entries in the map's primitive.
01:26
'print()' could be replaced by 'getMapFields().get("addr:housenumber")'.
01:27
es: /me thinking

Radomír: And the street will be obtained by 'getMapFields().get("addr:street")'
01:29
es: it will be defined in house class?

Radomír: Yes.
01:30
My point is:

In the CZ, we store "addr:housenumber = 168/32" together with all two additional tags "addr:streetnumber = 32" and "addr:conscriptionnumber=168".
01:31
The plugin must have a way of knowing about these "additional" tags.

es: I see your point

if we say.. that there could be any tag. Then there is no other way
01:32
Radomír: Yes, I afraid that's right.

Generally this is not a good programming practice, but I also see no other way.

es: mean... House class will know how to give back apropriate tags for it's country
01:33
Radomír: Yes.